/// <summary> /// Checks an entity to see if it satisfies a class constraint /// </summary> /// <typeparam name="TClass">Type of class to check.</typeparam> /// <param name="expected">Expected object to use</param> /// <param name="candidate">Candidate object to use</param> /// <param name="objectName">Name to use, displayed in error messages to disambiguate</param> /// <returns>true if the instance pass, otherwise false.</returns> protected static bool CheckClass <TClass>(object expected, object candidate, string objectName) where TClass : class { if (expected is TClass) { CheckerFactory.Check(expected as TClass, candidate as TClass, objectName); return(true); } return(false); }
/// <summary> /// Check the parent class of an entity /// </summary> /// <typeparam name="TClass">Type to cast the objects to.</typeparam> /// <param name="expected">Expected object to use</param> /// <param name="candidate">Candidate object to use</param> /// <param name="objectName">Name to use, displayed in error messages to disambiguate</param> protected static void CheckParentClass <TClass>(object expected, object candidate, string objectName) where TClass : class { CheckerFactory.CheckParent(expected as TClass, candidate as TClass, objectName); }