Not sure if I can do this or not, but I’m trying to see if a type inherits from another type with a generic constraint.
Here is the class I want to find:
public class WorkoutCommentStreamMap : ClassMapping<WorkoutCommentStream>...
And here is the test
var inheritableType = typeof(NHibernate.Mapping.ByCode.Conformist.ClassMapping<>);
var isMappedObject = inheritableType.IsAssignableFrom(typeof(WorkoutCommentStreamMap));
If I change the first line to below, it works. But that defeats the purpose of my example. My fallback work around is to put a custom, non-generic, interface on all the objects I want to find and use the same call.
var inheritableType = typeof(NHibernate.Mapping.ByCode.Conformist.ClassMapping<WorkoutCommentStream>);
There is not an inheritance relationship between a generic type definition and a closed generic type. Therefore,
IsAssignableFromwill not work.However, I use this little extension method to achieve what your after:
With sample usage: