Expose System.Type.IsSubclassOf(), .IsInstanceOfType(), .IsSubclassOf(), and .baseType
complete
Merlin
It would be nice to have .IsSubclassOf(), .IsInstanceOfType(), .IsSubclassOf(), and .baseType exposed so that we can do type checking at runtime for methods that return generic objects or some base class of a type. At the moment we can only compare types directly, so if we wanted to be completely correct about type checking, we'd need to manually check every potential inherited type which could easily get prohibitively expensive.
Log In
Fax
complete
Thank you for the request!
We just released this feature in SDK 3.7.1.
This post was marked as
available in future release
Momo the Monster
in progress
Merlin
Adding a more complete list of all methods/properties on System.Type that could find use and have no real issue with including:
SystemType.__get_DeclaringType__SystemType
SystemType.__get_ReflectedType__SystemType
SystemType.__get_BaseType__SystemType
SystemType.__get_IsNested__SystemBoolean
SystemType.__get_IsVisible__SystemBoolean
SystemType.__get_IsNotPublic__SystemBoolean
SystemType.__get_IsPublic__SystemBoolean
SystemType.__get_IsNestedPublic__SystemBoolean
SystemType.__get_IsNestedPrivate__SystemBoolean
SystemType.__get_IsNestedFamily__SystemBoolean
SystemType.__get_IsNestedAssembly__SystemBoolean
SystemType.__get_IsNestedFamANDAssem__SystemBoolean
SystemType.__get_IsNestedFamORAssem__SystemBoolean
SystemType.__get_IsAutoLayout__SystemBoolean
SystemType.__get_IsLayoutSequential__SystemBoolean
SystemType.__get_IsExplicitLayout__SystemBoolean
SystemType.__get_IsClass__SystemBoolean
SystemType.__get_IsInterface__SystemBoolean
SystemType.__get_IsValueType__SystemBoolean
SystemType.__get_IsAbstract__SystemBoolean
SystemType.__get_IsSealed__SystemBoolean
SystemType.__get_IsEnum__SystemBoolean
SystemType.__get_IsSpecialName__SystemBoolean
SystemType.__get_IsImport__SystemBoolean
SystemType.__get_IsSerializable__SystemBoolean
SystemType.__get_IsAnsiClass__SystemBoolean
SystemType.__get_IsUnicodeClass__SystemBoolean
SystemType.__get_IsAutoClass__SystemBoolean
SystemType.__get_IsArray__SystemBoolean
SystemType.__get_IsGenericType__SystemBoolean
SystemType.__get_IsGenericTypeDefinition__SystemBoolean
SystemType.__get_IsConstructedGenericType__SystemBoolean
SystemType.__get_IsGenericParameter__SystemBoolean
SystemType.__get_GenericParameterPosition__SystemInt32
SystemType.__get_ContainsGenericParameters__SystemBoolean
SystemType.__get_IsByRef__SystemBoolean
SystemType.__get_IsPointer__SystemBoolean
SystemType.__get_IsPrimitive__SystemBoolean
SystemType.__get_IsCOMObject__SystemBoolean
SystemType.__get_HasElementType__SystemBoolean
SystemType.__get_IsContextful__SystemBoolean
SystemType.__get_IsMarshalByRef__SystemBoolean
SystemType.__get_GenericTypeArguments__SystemTypeArray
SystemType.__get_IsSecurityCritical__SystemBoolean
SystemType.__get_IsSecuritySafeCritical__SystemBoolean
SystemType.__get_IsSecurityTransparent__SystemBoolean
SystemType.__get_UnderlyingSystemType__SystemType
SystemType.__get_IsSZArray__SystemBoolean
SystemType.__MakeByRefType__SystemType
SystemType.__MakeArrayType__SystemType
SystemType.__MakeArrayType__SystemInt32__SystemType
SystemType.__GetArrayRank__SystemInt32
SystemType.__GetGenericParameterConstraints__SystemTypeArray
SystemType.__MakeGenericType__SystemTypeArray__SystemType
SystemType.__GetElementType__SystemType
SystemType.__GetGenericArguments__SystemTypeArray
SystemType.__GetGenericTypeDefinition__SystemType
SystemType.__GetEnumNames__SystemStringArray
SystemType.__GetEnumValues__SystemArray
SystemType.__GetEnumUnderlyingType__SystemType
SystemType.__IsEnumDefined__SystemObject__SystemBoolean
SystemType.__GetEnumName__SystemObject__SystemString
SystemType.__IsSubclassOf__SystemType__SystemBoolean
SystemType.__IsInstanceOfType__SystemObject__SystemBoolean
SystemType.__IsAssignableFrom__SystemType__SystemBoolean
SystemType.__IsEquivalentTo__SystemType__SystemBoolean
SystemType.__GetTypeArray__SystemObjectArray__SystemTypeArray
Merlin
Looking at this again, I realize that I somehow managed to duplicate IsSubclassOf instead of writing the function that I actually meant, the second mention of IsSubclassOf was supposed to be requesting Type.IsAssignableFrom().
Another useful function for dealing with arrays of objects and such would be Type.GetElementType()