/// <summary> /// Extension method to check that the DTO thing instance is equal to, or a descendant of the supplied generic type T. /// </summary> /// <typeparam name="T"> /// Generic type parameter to check against /// </typeparam> /// <param name="thing"> /// The Thing instance on which the type check is performed /// </param> /// <returns> /// True if determined equal or descendant type. /// </returns> public static bool IsSameOrDerivedClass <T>(this Thing thing) { var potentialBase = typeof(T); var potentialDescendant = thing.GetType(); return(potentialDescendant.IsSubclassOf(potentialBase) || potentialDescendant == potentialBase); }