Interface IOpt
Type for options whose contained value type is not specified.
Inherited Members
Namespace: Hgk.Zero.Options
Assembly: Hgk.Zero.Options.dll
Syntax
public interface IOpt : IEnumerable
Remarks
An IOpt can be coerced to a typed option by using Cast<TResult>(IOpt), which forcibly casts the contained value to the specified type if necessary, or OfType<TResult>(IOpt), which produces an empty option if the contained value cannot be cast to the specified type.
IOpt implements the non-generic IEnumerable. The contract of this interface requires that the enumerator returned from GetEnumerator() produces either zero values, if the option is empty, or one value, if the option is full. Behavior is undefined if the enumerable produces more than one value.
In general, this interface should not be directly implemented in an application. Refer to IOpt<T> for preferred ways to obtain an option.
Methods
| Improve this Doc View SourceResolveUntypedOption<TResult>(Func<Boolean, Object, TResult>)
Resolves the Object-typed contents of this option, producing a result using the specified result selector function.
Declaration
TResult ResolveUntypedOption<TResult>(Func<bool, object, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean, Object, TResult> | resultSelector | A transform function that accepts a has-value flag and a value. |
Returns
Type | Description |
---|---|
TResult | The result of calling |
Type Parameters
Name | Description |
---|---|
TResult | The return type of |
Remarks
The resolver function accepts two parameters: A has-value flag and a value. (These values roughly correspond to Any<TSource>(IOpt<TSource>) and SingleOrDefault<TSource>(IOpt<TSource>), respectively.)
- If this option contains a value, the has-value flag is true and the value parameter is the contained value.
- If this option is empty, the has-value flag is false and the value parameter is undefined. (The caller must not use the value of the value parameter. In order to prevent accidental misbehavior, the implementation should supply null, but this is not required.)
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|