GSF.TypeExtensions.GetRootType C# (CSharp) Method

GetRootType() public static method

Gets the root type in the inheritance hierarchy from which the specified type inherits.
Unless input type is object or MarshalByRefObject, the returned type will never be object or MarshalByRefObject, even though all types ultimately inherit from either one of them.
public static GetRootType ( this type ) : Type
type this The whose root type is to be found.
return System.Type
        public static Type GetRootType(this Type type)
        {
            // Recurse through types until you reach a base type of "System.Object" or "System.MarshalByRef".
#if MONO
            // TODO: Test with Mono to see if type comparison now works as expected
            if ((object)type.BaseType == null || type.BaseType.FullName.Equals("System.Object", StringComparison.Ordinal) || type.BaseType.FullName.Equals("System.MarshalByRefObject", StringComparison.Ordinal))
#else
            if ((object)type.BaseType == null || type.BaseType == typeof(object) || type.BaseType == typeof(MarshalByRefObject))
#endif
                return type;

            return GetRootType(type.BaseType);
        }
    }