Пример #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));
 }