Show / Hide Table of Contents

Class Opt

Facilities to create and manipulate options.

Inheritance
Object
Opt
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Hgk.Zero.Options
Assembly: Hgk.Zero.Options.dll
Syntax
public static class Opt

Methods

| Improve this Doc View Source

Create<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 value if it is not null; otherwise, an empty option.

Type Parameters
Name Description
T

The type of value.

See Also
Create<T>(Nullable<T>)
Empty<T>()
Full<T>(T)
Create<T>(Boolean, T)
| Improve this Doc View Source

Create<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 hasValue is true.

Returns
Type Description
Opt<T>

An option that contains value, if hasValue is true; otherwise, an empty option.

Type Parameters
Name Description
T

The type of value.

See Also
Create<T>(T)
Create<T>(Nullable<T>)
Empty<T>()
Full<T>(T)
| Improve this Doc View Source

Create<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 value, if present; otherwise, an empty option.

Type Parameters
Name Description
T

The non-nullable basis type of value.

See Also
Create<T>(T)
Empty<T>()
Full<T>(T)
Create<T>(Boolean, T)
| Improve this Doc View Source

Defer<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 toFixedFunction.

Type Parameters
Name Description
T

The contained element type of the new option.

Exceptions
Type Condition
ArgumentNullException

toFixedFunction is null.

| Improve this Doc View Source

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
Full<T>(T)
Create<T>(T)
Create<T>(Nullable<T>)
Create<T>(Boolean, T)
| Improve this Doc View Source

Fix<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 source.

Type Parameters
Name Description
TSource

The element type of source.

| Improve this Doc View Source

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 source.

| Improve this Doc View Source

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

Type Parameters
Name Description
T

The type of value.

See Also
Empty<T>()
Create<T>(T)
Create<T>(Nullable<T>)
Create<T>(Boolean, T)
  • Improve this Doc
  • View Source
Back to top Copyright © 2018-2019 Peter S. May
Generated by DocFX