ApplyMaxLengthAttribute ..
Used to mutate a string data to the maximum allowable length according to the associated StringLengthAttribute.MaximumLength or MaxLengthAttribute.Length.
Namespace: Dado.ComponentModel.DataMutations
Implements: Dado.ComponentModel.DataMutations.MutationAttribute (in Dado.ComponentModel.Mutations)
[AttributeUsage(AttributeTargets.Property)]
public class ApplyMaxLengthAttribute : MutationAttributeSince System.Attributes cannot accept generics or lambdas, there is not a practical way to alter the length of collections maintaining their type information. Therefore, ApplyMaxLengthAttribute.CollectionDescriptor can be used to extend ApplyMaxLengthAttribute through its protected constructor.
Expect ApplyMaxLengthAttribute.CollectionDescriptor to be obsolete once generics or lambdas are implemented for System.Attributes.
| Name | Description |
|---|---|
| ApplyMaxLengthAttribute() | Initializes a new instance of the ApplyMaxLengthAttribute class. |
| ApplyMaxLengthAttribute(CollectionDescriptor) | Initializes a new instance of the ApplyMaxLengthAttribute class. |
| Name | Description |
|---|---|
| Priority | Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. |
| RequiresContext | A flag indicating the attribute requires a non-null IMutationContext to perform validation. |
| Name | Description |
|---|---|
| Mutate(Object, IMutationContext) | Mutates the given value according to this MutationAttribute. |
| Mutate(Object, Int32) | Mutates the given value according to this MutationAttribute. |
| MutateValue(Object, IMutationContext) | Implements the mutation logic for this ToDefaultValueAttribute. |
Initializes a new instance of the ApplyMaxLengthAttribute class.
public ApplyMaxLengthAttribute()Initializes a new instance of the ApplyMaxLengthAttribute class.
protected ApplyMaxLengthAttribute(
CollectionDescriptor descriptor
)- descriptor
- Type: Dado.ComponentModel.DataMutations.ApplyMaxLengthAttribute.CollectionDescriptor
Describe a collection should be mutated.
A flag indicating the attribute requires a non-null IMutationContext to perform validation. Returns true.
public override bool RequiresContext { get; protected set; } = true;- Type
- System.Boolean
Mutates the given value according to this MutationAttribute.
public object Mutate(
object value,
int maximumLength
)The resulting mutated value.
- value
- Type: System.Object
The value to mutate. - maximumLength
- Type: System.Int32
The maximum allowable length to apply to the string data.
Implements the mutation logic for this ApplyMaxLengthAttribute.
protected override object MutateValue(
object value,
IMutationContext context
)The truncated string data when the specified value exceeds the maximum allowable length.
- value
- Type: System.Object
The value to mutate. - context
- Type: Dado.ComponentModel.DataMutations.IMutationContext
Describes thevaluebeing mutated and provides services and context for mutation.