I am trying to generalize some builder repetative method calls. I have some entities and trying to achieve call standard methods if they have implemented some if the interfaces. Here is what I am trying to achieve in code:
void MainMethod(){
...
HandleStandards<MyClass>(builder);
...
}
void HandleStandards<T>(..builder..) where T: class, IEntity
{
// of course my problem is with here. because T is not suitable to pass to other methods
if(T is IIdentifiable){
HandleIdentifiable<T>(builder);
}
if(T is ITrackable){
HandleTrackable<T>(builder);
}
}
void HandleIdentifiable<T>(..builder..) where T: class, IEntity, IIdentifiable
{
...
}
void HandleTrackable<T>(..builder..) where T: class, IEntity, ITrackable
{
...
}
Is there a way to type check a generic type and pass it to another generic method?