示例#1
0
 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");
示例#2
0
 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");
示例#3
0
 /// <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;
示例#4
0
 /// <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;
示例#5
0
 /// <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);
示例#6
0
 /// <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));
 }