In This Article

NumberPartBase<T> Class

Represents a numeric part that uses a format for text conversion.

public abstract class NumberPartBase<T> : FormattedPartBase<T?>, IPart where T : struct, INumber<T>, IMinMaxValue<T>
Type Parameters:
T -

The part value type.

Inheritance:
object PartBase<T?> FormattedPartBase<T?> object
Derived:
NumberPart<T>
Implements:
IPart

Constructors

NumberPartBase(string?)

Initializes an instance of the class.

protected NumberPartBase(string? format = null)
Parameter Type Description
format string

The numeric or composite format.

Properties

DefaultLargeChange

The default value used for a large change.

public T DefaultLargeChange { get; set; }

Property Value

T:

The default value is 5.

DefaultSmallChange

The default value used for a small change.

public T DefaultSmallChange { get; set; }

Property Value

T:

The default value is 1.

IsComposited

Indicates whether the part is composited with other parts in an exit box.

protected virtual bool IsComposited { get; }

Property Value

bool:

true if the part is composited with other parts in an exit box; otherwise, false.

MaximumValue

The maximum allowed value.

public T MaximumValue { get; set; }

Property Value

T:

The default value is the maximum value allowed for the type (e.g., Int32.MaxValue).

MinimumValue

The minimum allowed value.

public T MinimumValue { get; set; }

Property Value

T:

The default value is the minimum value allowed for the type (e.g., Int32.MinValue).

Methods

IncrementValue(T, T, bool, T, T, SpinWrapping, int, bool)

Increments a value.

protected virtual T IncrementValue(T value, T delta, bool isIncreasing, T minimum, T maximum, SpinWrapping spinWrapping, int roundingDecimalPlace, bool canSnapToChangePrecision)
Parameter Type Description
value T

The current value.

delta T

The value of the incremental change.

isIncreasing bool

true if the value should be increased by the delta; otherwise false to decrease the value by the delta.

minimum T

The minimum allowed value.

maximum T

The maximum allowed value.

spinWrapping SpinWrapping

The wrapping behavior used when spinning past a minimum or maximum value.

roundingDecimalPlace int

(For floating point numbers only) The rounding decimal place. Pass a negative number to disable rounding.

canSnapToChangePrecision bool

(For floating point numbers only) Whether the value should be snapped to the precision of the incremental change value prior to applying the increment.

Returns

T:

The incremented value.

TryParseText(IList<IPart>, string, int, CultureInfo, out int)

Tries to parse the text starting offset and returns the offset through which parsing was completed.

public override bool TryParseText(IList<IPart> parts, string text, int startOffset, CultureInfo culture, out int offset)
Parameter Type Description
parts IList<IPart>

The part collection in which this part is a member.

text string

The text to examine.

startOffset int

The start offset.

culture CultureInfo

The CultureInfo to use.

offset int

Returns the offset through which parsing was completed.

Returns

bool:

true if parsing was successful; otherwise, false.

Inherited Members

Extension Methods