概要
<summary>
</summary>
public static bool IsInherits( this Type self, Type baseOrInterfaceType )
{
if ( self == null ) return false;
if ( baseOrInterfaceType == null ) return self.IsInterface || self == typeof( object );
if ( baseOrInterfaceType.IsInterface ) return self.GetInterfaces().Contains( baseOrInterfaceType );
var currentType = self;
while ( currentType != null )
{
if ( currentType.BaseType == baseOrInterfaceType ) return true;
currentType = currentType.BaseType;
}
return false;
}
参考サイト様