Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Latest commit

 

History

History
166 lines (109 loc) · 4.14 KB

File metadata and controls

166 lines (109 loc) · 4.14 KB

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)

Syntax

[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class ReplaceAttribute : MutationAttribute

Remarks

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.

Constructors

Name Description
ReplaceAttribute(String) Initializes a new instance of the ReplaceAttribute class.
ReplaceAttribute(String[]) Initializes a new instance of the ReplaceAttribute class.

Properties

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.

Methods

Name Description
Mutate(Object, IMutationContext) Mutates the given value according to this MutationAttribute.
MutateValue(Object, IMutationContext) Implements the mutation logic for this ReplaceAttribute.

ReplaceAttribute(String)

Initializes a new instance of the ReplaceAttribute class.

Syntax

public ReplaceAttribute(
	string antecedent
)

Parameters

antecedent
Type: System.String
The string to be replaced.

ReplaceAttribute(String[])

Initializes a new instance of the ReplaceAttribute class.

Syntax

public ReplaceAttribute(
	params string[] antecedents
)

Parameters

antecedents
Type: System.String[]
The strings to be replaced.

Antecedents

Gets the values to be replaced in a string.

Syntax

public IEnumerable<string> Antecedents { get; private set; }
Type
System.Collections.Generic.IEnumerable<System.String>

Priority

Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. Defaults to 20.

Syntax

public override int Priority { get; set; } = 20;
Type
System.Int32

Replacement

Gets or sets the string to replace all occurrences of the specified Antecedents.

Syntax

public string Replacement { get; set; }
Type
System.String

MutateValue(Object, IMutationContext)

Implements the mutation logic for this ReplaceAttribute.

Syntax

protected override object MutateValue(
	object value,
	IMutationContext context
)

Returns

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.

Parameters

value
Type: System.Object
The value to mutate.
context
Type: Dado.ComponentModel.DataMutations.IMutationContext
Describes the value being mutated and provides services and context for mutation.