Exemple #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");
Exemple #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");
Exemple #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;
Exemple #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;
Exemple #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);
Exemple #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));
 }