Class AllowedTypesAttribute
Assigns types that the property accept or restrict adding.
Inheritance
Namespace: EPiServer.DataAnnotations
Assembly: EPiServer.dll
Version: 12.0.3Syntax
public sealed class AllowedTypesAttribute : ValidationAttribute
Constructors
AllowedTypesAttribute()
Initializes a new instance of the AllowedTypesAttribute class.
Declaration
public AllowedTypesAttribute()
AllowedTypesAttribute(Type[])
Initializes a new instance of the AllowedTypesAttribute class.
Declaration
public AllowedTypesAttribute(params Type[] allowedTypes)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | allowedTypes | The allowed types. The null value is replaced with IContentData. |
AllowedTypesAttribute(Type[], Type[])
Initializes a new instance of the AllowedTypesAttribute class.
Declaration
public AllowedTypesAttribute(Type[] allowedTypes, Type[] restrictedTypes)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | allowedTypes | The allowed types. The null value is replaced with IContentData. |
System.Type[] | restrictedTypes | The restricted types |
AllowedTypesAttribute(Type[], Type[], String)
Initializes a new instance of the AllowedTypesAttribute class.
Declaration
public AllowedTypesAttribute(Type[] allowedTypes, Type[] restrictedTypes, string typesFormatSuffix)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | allowedTypes | The allowed types. The null value is replaced with IContentData. |
System.Type[] | restrictedTypes | The restricted types |
System.String | typesFormatSuffix | The TypesFormatSuffix |
Properties
AllowedTypes
Gets or sets the allowed types.
Declaration
public Type[] AllowedTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Type[] | The allowed types. |
Remarks
Setting value null is treated as all IContentData types are allowed.
RestrictedTypes has presence over AllowedTypes meaning that if the instance is assignable to any type in RestrictedTypes then will it not be allowed regardless if the type is assignable to any type in AllowedTypes.
RestrictedTypes
Gets types which the property is not allowed to contain.
Declaration
public Type[] RestrictedTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Type[] |
Remarks
RestrictedTypes has presence over AllowedTypes meaning that if the instance is assignable to any type in RestrictedTypes then will it not be allowed regardless if the type is assignable to any type in AllowedTypes.
TypesFormatSuffix
Gets or sets types format suffix.
Declaration
public string TypesFormatSuffix { get; set; }
Property Value
Type | Description |
---|---|
System.String | The types format suffix. |
Methods
IsValid(Object, ValidationContext)
Declaration
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | |
System.ComponentModel.DataAnnotations.ValidationContext | validationContext |
Returns
Type | Description |
---|---|
System.ComponentModel.DataAnnotations.ValidationResult |