ReplaceAttribute ..
Used to mutate a string so all occurrences of a specified strings are replaced with another specified string.
Namespace: Dado.ComponentModel.DataMutations
Implements: Dado.ComponentModel.DataMutations.MutationAttribute (in Dado.ComponentModel.Mutations)
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class ReplaceAttribute : MutationAttribute
If Replacement is null, all occurrences of the specified Antecedents are removed.
This attribute performs an ordinal (case-sensitive and culture-insensitive) search to find the specified Antecedents.
Name | Description |
---|---|
ReplaceAttribute(String) | Initializes a new instance of the ReplaceAttribute class. |
ReplaceAttribute(String[]) | Initializes a new instance of the ReplaceAttribute class. |
Name | Description |
---|---|
Antecedents | Gets the values to be replaced in a string. |
Priority | Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. |
Replacement | Gets or sets the string to replace all occurrences of the specified Antecedents. |
RequiresContext | A flag indicating the attribute requires a non-null MutationContext<T> to perform validation. |
Name | Description |
---|---|
Mutate(Object, IMutationContext) | Mutates the given value according to this MutationAttribute. |
MutateValue(Object, IMutationContext) | Implements the mutation logic for this ReplaceAttribute. |
Initializes a new instance of the ReplaceAttribute class.
public ReplaceAttribute(
string antecedent
)
- antecedent
- Type: System.String
The string to be replaced.
Initializes a new instance of the ReplaceAttribute class.
public ReplaceAttribute(
params string[] antecedents
)
- antecedents
- Type: System.String[]
The strings to be replaced.
Gets the values to be replaced in a string.
public IEnumerable<string> Antecedents { get; private set; }
- Type
- System.Collections.Generic.IEnumerable<System.String>
Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. Defaults to 20
.
public override int Priority { get; set; } = 20;
- Type
- System.Int32
Gets or sets the string to replace all occurrences of the specified Antecedents.
public string Replacement { get; set; }
- Type
- System.String
Implements the mutation logic for this ReplaceAttribute.
protected override object MutateValue(
object value,
IMutationContext context
)
A string that is equivalent to the current value
except that all instances of specified Antecedents are replaced with the value of Replacement. If none of the Antecedents are found in the current value
, the method returns the current value
unchanged.
- value
- Type: System.Object
The value to mutate. - context
- Type: Dado.ComponentModel.DataMutations.IMutationContext
Describes thevalue
being mutated and provides services and context for mutation.