public static string AbstractValidationMessage <TAttribute>(TypeAttribute <TAttribute> attribute, string prefix = null) where TAttribute : Attribute => GetTypePropertyValidationString(prefix, attribute.Type.FullName, $"{(attribute.Type.IsAbstract ? "not " : "")} be abstract");
public static string GenericValidationMessage <TAttribute>(TypeAttribute <TAttribute> attribute, string prefix = null) where TAttribute : Attribute => GetTypePropertyValidationString(prefix, attribute.Type.FullName, $"{(attribute.Type.IsGenericType ? "not " : "")}be generic");
/// <summary> /// Checks whether the type is an abstract type. /// </summary> /// <param name="typeAttribute">The <see cref="TypeAttribute{TAttribute}"/> instance to check<./param> /// <returns>True if the type satisfies the constraint, false otherwise.</returns> public bool SatisfiesConstraint(TypeAttribute <TAttribute> typeAttribute) => typeAttribute.Type.IsAbstract;
/// <summary> /// Checks whether the type is not a generic type. /// </summary> /// <param name="typeAttribute">The <see cref="TypeAttribute{TAttribute}"/> instance to check.</param> /// <returns>True if the type satisfies the constraint, false otherwise.</returns> public bool SatisfiesConstraint(TypeAttribute <TAttribute> typeAttribute) => !typeAttribute.Type.IsGenericType;
/// <summary> /// Checks whether the type is a non-static type. /// </summary> /// <param name="typeAttribute">The <see cref="TypeAttribute{TAttribute}"/> instance to check.</param> /// <returns>True if the type satisfies the constraint, false otherwise.</returns> public bool SatisfiesConstraint(TypeAttribute <TAttribute> typeAttribute) => !(typeAttribute.Type.IsSealed && typeAttribute.Type.IsAbstract);
/// <summary> /// Checks whether the type is a subclass of the provided type. /// </summary> /// <param name="typeAttribute">The <see cref="TypeAttribute{TAttribute}"/> instance to check.</param> /// <param name="parentType"></param> /// <returns>True if the type satisfies the constraint, false otherwise.</returns> public bool SatisfiesConstraint(TypeAttribute <TAttribute> typeAttribute, Type parentType) { return(typeAttribute.Type.IsSubclassOf(parentType)); }