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

Latest commit

 

History

History
109 lines (73 loc) · 2.87 KB

ToNumericAttribute.md

File metadata and controls

109 lines (73 loc) · 2.87 KB

ToNumericAttribute ..

Used to mutate a string to allow only numeric characters.

Namespace: Dado.ComponentModel.DataMutations
Implements: Dado.ComponentModel.DataMutations.MutationAttribute (in Dado.ComponentModel.Mutations)

Syntax

[AttributeUsage(AttributeTargets.Property)]
public class ToNumericAttribute : MutationAttribute

Properties

Name Description
PreserveFloatingPoint Gets or sets a value indicating whether a floating point indication (.) should be preserved during mutation.
PreserveSign Gets or sets a value indicating whether a sign indication (±) should be preserved during mutation.
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 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 ToNumericAttribute.

PreserveFloatingPoint

Gets or sets a value indicating whether a floating point indication (.) should be preserved during mutation.

Syntax

public bool PreserveFloatingPoint { get; set; }
Type
System.Boolean

PreserveSign

Gets or sets a value indicating whether a sign indication (±) should be preserved during mutation.

Syntax

public bool PreserveSign { get; set; }
Type
System.Boolean

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

MutateValue(Object, IMutationContext)

Implements the mutation logic for this ToNumericAttribute.

Syntax

protected override object MutateValue(
	object value,
	IMutationContext context
)

Returns

The resulting mutated value in the specified numeric format.

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.