Class Opt
Facilities to create and manipulate options.
Inherited Members
Namespace: Hgk.Zero.Options
Assembly: Hgk.Zero.Options.dll
Syntax
public static class Opt
Methods
| Improve this Doc View SourceCreate<T>(T)
Creates a fixed option which contains the specified value, if it is not null.
Declaration
public static Opt<T> Create<T>(T value)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be contained in the new option, if not null. |
Returns
Type | Description |
---|---|
Opt<T> | An option that contains |
Type Parameters
Name | Description |
---|---|
T | The type of |
See Also
| Improve this Doc View SourceCreate<T>(Boolean, T)
Creates a fixed option which contains the specified value, if a flag is set.
Declaration
public static Opt<T> Create<T>(bool hasValue, T value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | hasValue | A flag to determine whether to produce a full option. |
T | value | The value to be contained in the new option, if |
Returns
Type | Description |
---|---|
Opt<T> | An option that contains |
Type Parameters
Name | Description |
---|---|
T | The type of |
See Also
| Improve this Doc View SourceCreate<T>(Nullable<T>)
Creates a fixed option with the same contents as the specified Nullable<T>.
Declaration
public static Opt<T> Create<T>(T? value)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Nullable<T> | value | The value to be contained in the new option, if not null. |
Returns
Type | Description |
---|---|
Opt<T> | An option that contains the Value of |
Type Parameters
Name | Description |
---|---|
T | The non-nullable basis type of |
See Also
| Improve this Doc View SourceDefer<T>(Func<Opt<T>>)
Creates a deferred option based on a factory function that returns a fixed option.
Declaration
public static IOpt<T> Defer<T>(this Func<Opt<T>> toFixedFunction)
Parameters
Type | Name | Description |
---|---|---|
Func<Opt<T>> | toFixedFunction | A function that returns an Opt<T> reflecting the current state of the option. |
Returns
Type | Description |
---|---|
IOpt<T> | An option for which the current state is resolved by calling |
Type Parameters
Name | Description |
---|---|
T | The contained element type of the new option. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Empty<T>()
Creates a fixed, empty option.
Declaration
public static Opt<T> Empty<T>()
Returns
Type | Description |
---|---|
Opt<T> | An empty option. |
Type Parameters
Name | Description |
---|---|
T | The element type of the new option. |
See Also
| Improve this Doc View SourceFix<TSource>(IOpt<TSource>)
Returns a fixed option reflecting the current state of an option.
Declaration
public static Opt<TSource> Fix<TSource>(IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
Opt<TSource> | A fixed option reflecting the current state of |
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
FixUntyped(IOpt)
Returns a fixed option reflecting the current state of an option.
Declaration
public static Opt<object> FixUntyped(IOpt source)
Parameters
Type | Name | Description |
---|---|---|
IOpt | source | A source option. |
Returns
Type | Description |
---|---|
Opt<Object> | A fixed option reflecting the current state of |
Full<T>(T)
Creates a fixed option that contains the specified value (even if the value is null).
Declaration
public static Opt<T> Full<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be contained in the new option. |
Returns
Type | Description |
---|---|
Opt<T> | An option that contains |
Type Parameters
Name | Description |
---|---|
T | The type of |