Struct FormValue
- Namespace
- RDCore.Forms.Model
- Assembly
- RDCore.Forms.dll
A value passed to or returned by a member of a form or a control, or passed to an event's handler: a kind and the CLR value of that kind.
public readonly struct FormValue : IEquatable<FormValue>
- Implements
- Inherited Members
Remarks
A form value converts nothing. A control receives a value of the type its member declares, because the code that runs the form let-coerces it before the call, a late-bound call included. A control that cannot take a value it is given answers with a FormError.
Properties
ClrValue
The CLR value held: null for Empty, Null and
Nothing; otherwise a value of the CLR type its Kind names.
public object? ClrValue { get; }
Property Value
Empty
The uninitialized value.
public static FormValue Empty { get; }
Property Value
Kind
The kind of value held.
public FormValueKind Kind { get; }
Property Value
Nothing
The object value Nothing.
public static FormValue Nothing { get; }
Property Value
Null
The value Null.
public static FormValue Null { get; }
Property Value
Methods
AsArray()
The array held.
public FormArray AsArray()
Returns
- FormArray
The array.
Exceptions
- InvalidOperationException
The value is not an array.
AsBoolean()
The Boolean held.
public bool AsBoolean()
Returns
- bool
The value.
Exceptions
- InvalidOperationException
The value is not a Boolean.
AsByte()
The Byte held.
public byte AsByte()
Returns
- byte
The value.
Exceptions
- InvalidOperationException
The value is not a Byte.
AsCurrency()
The Currency held.
public decimal AsCurrency()
Returns
- decimal
The value.
Exceptions
- InvalidOperationException
The value is not a Currency.
AsDate()
The Date held.
public DateTime AsDate()
Returns
- DateTime
The value.
Exceptions
- InvalidOperationException
The value is not a Date.
AsDecimal()
The Decimal held.
public decimal AsDecimal()
Returns
- decimal
The value.
Exceptions
- InvalidOperationException
The value is not a Decimal.
AsDouble()
The Double held.
public double AsDouble()
Returns
- double
The value.
Exceptions
- InvalidOperationException
The value is not a Double.
AsError()
The number of the error value held.
public int AsError()
Returns
- int
The error's number.
Exceptions
- InvalidOperationException
The value is not an error value.
AsInteger()
The Integer held.
public short AsInteger()
Returns
- short
The value.
Exceptions
- InvalidOperationException
The value is not an Integer.
AsLong()
The Long held.
public int AsLong()
Returns
- int
The value.
Exceptions
- InvalidOperationException
The value is not a Long.
AsLongLong()
The LongLong held.
public long AsLongLong()
Returns
- long
The value.
Exceptions
- InvalidOperationException
The value is not a LongLong.
AsObject()
The object held, or null for Nothing.
public object? AsObject()
Returns
- object
The object.
Exceptions
- InvalidOperationException
The value is not an object.
AsSingle()
The Single held.
public float AsSingle()
Returns
- float
The value.
Exceptions
- InvalidOperationException
The value is not a Single.
AsString()
The String held.
public string AsString()
Returns
- string
The value.
Exceptions
- InvalidOperationException
The value is not a String.
Equals(FormValue)
Whether two values are of the same kind and hold equal CLR values. Two objects are equal when they are the same object, and two arrays when they are the same array.
public bool Equals(FormValue other)
Parameters
otherFormValueThe other value.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FromArray(FormArray)
An array.
public static FormValue FromArray(FormArray array)
Parameters
arrayFormArrayThe array.
Returns
- FormValue
The form value.
Exceptions
- ArgumentNullException
arrayis null.
FromBoolean(bool)
A Boolean.
public static FormValue FromBoolean(bool value)
Parameters
valueboolThe value.
Returns
- FormValue
The form value.
FromByte(byte)
A Byte.
public static FormValue FromByte(byte value)
Parameters
valuebyteThe value.
Returns
- FormValue
The form value.
FromCurrency(decimal)
A Currency.
public static FormValue FromCurrency(decimal value)
Parameters
valuedecimalThe value.
Returns
- FormValue
The form value.
FromDate(DateTime)
A Date.
public static FormValue FromDate(DateTime value)
Parameters
valueDateTimeThe value.
Returns
- FormValue
The form value.
FromDecimal(decimal)
A Decimal.
public static FormValue FromDecimal(decimal value)
Parameters
valuedecimalThe value.
Returns
- FormValue
The form value.
FromDouble(double)
A Double.
public static FormValue FromDouble(double value)
Parameters
valuedoubleThe value.
Returns
- FormValue
The form value.
FromError(int)
An error value.
public static FormValue FromError(int number)
Parameters
numberintThe error's number.
Returns
- FormValue
The form value.
FromInteger(short)
An Integer.
public static FormValue FromInteger(short value)
Parameters
valueshortThe value.
Returns
- FormValue
The form value.
FromLong(int)
A Long.
public static FormValue FromLong(int value)
Parameters
valueintThe value.
Returns
- FormValue
The form value.
FromLongLong(long)
A LongLong.
public static FormValue FromLongLong(long value)
Parameters
valuelongThe value.
Returns
- FormValue
The form value.
FromObject(object?)
An object, or Nothing for null.
public static FormValue FromObject(object? target)
Parameters
targetobjectThe object.
Returns
- FormValue
The form value.
FromSingle(float)
A Single.
public static FormValue FromSingle(float value)
Parameters
valuefloatThe value.
Returns
- FormValue
The form value.
FromString(string)
A String.
public static FormValue FromString(string value)
Parameters
valuestringThe value.
Returns
- FormValue
The form value.
Exceptions
- ArgumentNullException
valueis null.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
The value's kind and CLR value, for diagnostics.
public override string ToString()
Returns
- string
A description of the value, such as
Long 42.
Operators
operator ==(FormValue, FormValue)
Whether two values are equal, as Equals(FormValue) compares them.
public static bool operator ==(FormValue left, FormValue right)
Parameters
Returns
operator !=(FormValue, FormValue)
Whether two values differ, as Equals(FormValue) compares them.
public static bool operator !=(FormValue left, FormValue right)