Table of Contents

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

object

Empty

The uninitialized value.

public static FormValue Empty { get; }

Property Value

FormValue

Kind

The kind of value held.

public FormValueKind Kind { get; }

Property Value

FormValueKind

Nothing

The object value Nothing.

public static FormValue Nothing { get; }

Property Value

FormValue

Null

The value Null.

public static FormValue Null { get; }

Property Value

FormValue

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

other FormValue

The other value.

Returns

bool

true when the values are equal.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromArray(FormArray)

An array.

public static FormValue FromArray(FormArray array)

Parameters

array FormArray

The array.

Returns

FormValue

The form value.

Exceptions

ArgumentNullException

array is null.

FromBoolean(bool)

A Boolean.

public static FormValue FromBoolean(bool value)

Parameters

value bool

The value.

Returns

FormValue

The form value.

FromByte(byte)

A Byte.

public static FormValue FromByte(byte value)

Parameters

value byte

The value.

Returns

FormValue

The form value.

FromCurrency(decimal)

A Currency.

public static FormValue FromCurrency(decimal value)

Parameters

value decimal

The value.

Returns

FormValue

The form value.

FromDate(DateTime)

A Date.

public static FormValue FromDate(DateTime value)

Parameters

value DateTime

The value.

Returns

FormValue

The form value.

FromDecimal(decimal)

A Decimal.

public static FormValue FromDecimal(decimal value)

Parameters

value decimal

The value.

Returns

FormValue

The form value.

FromDouble(double)

A Double.

public static FormValue FromDouble(double value)

Parameters

value double

The value.

Returns

FormValue

The form value.

FromError(int)

An error value.

public static FormValue FromError(int number)

Parameters

number int

The error's number.

Returns

FormValue

The form value.

FromInteger(short)

An Integer.

public static FormValue FromInteger(short value)

Parameters

value short

The value.

Returns

FormValue

The form value.

FromLong(int)

A Long.

public static FormValue FromLong(int value)

Parameters

value int

The value.

Returns

FormValue

The form value.

FromLongLong(long)

A LongLong.

public static FormValue FromLongLong(long value)

Parameters

value long

The value.

Returns

FormValue

The form value.

FromObject(object?)

An object, or Nothing for null.

public static FormValue FromObject(object? target)

Parameters

target object

The object.

Returns

FormValue

The form value.

FromSingle(float)

A Single.

public static FormValue FromSingle(float value)

Parameters

value float

The value.

Returns

FormValue

The form value.

FromString(string)

A String.

public static FormValue FromString(string value)

Parameters

value string

The value.

Returns

FormValue

The form value.

Exceptions

ArgumentNullException

value is 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

left FormValue

The first value.

right FormValue

The second value.

Returns

bool

true when the values are equal.

operator !=(FormValue, FormValue)

Whether two values differ, as Equals(FormValue) compares them.

public static bool operator !=(FormValue left, FormValue right)

Parameters

left FormValue

The first value.

right FormValue

The second value.

Returns

bool

true when the values differ.