TimeSpanStepAttribute

Ecng.ComponentModel

Validates that a TimeSpan value lies on a discrete grid defined by Base + n * Step (in ticks).

Hereda de: StepAttribute

Implementa: IValidator

Constructores

TimeSpanStepAttribute
public TimeSpanStepAttribute(TimeSpan step, TimeSpan baseValue)
timeSpanStepAttribute = TimeSpanStepAttribute(step, baseValue)

Creates a new instance using TimeSpan values.

step
Positive step.
baseValue
Base offset (default TimeSpan.Zero).
TimeSpanStepAttribute
public TimeSpanStepAttribute(long stepMilliseconds, long baseMilliseconds)
timeSpanStepAttribute = TimeSpanStepAttribute(stepMilliseconds, baseMilliseconds)

Creates a new instance using millisecond step/base.

stepMilliseconds
Positive step in milliseconds.
baseMilliseconds
Base offset in milliseconds (default 0).
TimeSpanStepAttribute
public TimeSpanStepAttribute(string step, string baseValue)
timeSpanStepAttribute = TimeSpanStepAttribute(step, baseValue)

Creates a new instance using TimeSpan strings (standard TimeSpan.Parse formats).

step
Positive step (e.g. "00:00:05" or "0:0:5").
baseValue
Base offset (default 00:00:00).

Propiedades

BaseTicks
public long BaseTicks { get; }
value = timeSpanStepAttribute.BaseTicks

Base offset in ticks.

StepTicks
public long StepTicks { get; }
value = timeSpanStepAttribute.StepTicks

Step in ticks (always > 0).

Métodos

IsValid
public override bool IsValid(object value)
result = timeSpanStepAttribute.IsValid(value)

Validates the specified value by converting it and applying the custom validation.

value
The value to validate.

Devuelve: True if the value is valid; otherwise, false.