Show / Hide Table of Contents
  • MaybeSharp
    • Maybe<T>
      • As
      • Bind
      • Cast
      • CompareTo
      • Equality
      • Equals
      • Explicit
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • HasValue
      • Implicit
      • Inequality
      • IsEmpty
      • LessThan
      • LessThanOrEqual
      • Maybe
      • Nothing
      • ToString
      • Value
  • MaybeSharp.Extensions
    • MaybeDictionaryExtensions
      • TryGetValue
    • MaybeExtensions
      • Coalesce
      • Or
      • Select
      • SelectMany
      • SelectNonempty
      • ToNullable
      • ValueOr
      • ValueOrException
      • WhenNothing
      • WhenSomething
      • Where
    • MaybeStringExtensions
      • TryParseBoolean
      • TryParseByte
      • TryParseChar
      • TryParseDateTime
      • TryParseDateTimeOffset
      • TryParseDecimal
      • TryParseDouble
      • TryParseInt
      • TryParseInt16
      • TryParseInt64
      • TryParseSingle
    • NullableExtensions
      • ToMaybe

Class MaybeExtensions

Provides extensions to the Maybe<T> type.

Inheritance
System.Object
MaybeExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: MaybeSharp.Extensions
Assembly: cs.temp.dll.dll
Syntax
public static class MaybeExtensions

Methods

Name Description
Coalesce<T>(Maybe<T>, IEnumerable<Maybe<T>>)

Coalesces this value with one or more others. If source is non-empty it is returned, otherwise the first non-empty value from values is returned. If all values are empty, the last empty value is returned.

Coalesce<T>(Maybe<T>, Maybe<T>[])

Coalesces this value with one or more others. If source is non-empty it is returned, otherwise the first non-empty value from values is returned. If all values are empty, the last empty value is returned.

Or<T>(Maybe<T>, Maybe<T>)

Coalesces this value with another. If this value is empty, other is returned, otherwise this is returned.

Select<T, TResult>(IEnumerable<Maybe<T>>, Func<T, Maybe<TResult>>)

Converts an of Maybe<T> values to a set of Maybe{TResult} values.

Select<T, TResult>(Maybe<T>, Func<T, TResult>)

Converts a Maybe<T> to a Maybe{TResult} using the function provided.

Select<T, TResult>(Maybe<T>, Func<T, Maybe<TResult>>)

Converts a Maybe<T> to a Maybe{TResult} using the function provided.

SelectMany<T, TOther, TResult>(Maybe<T>, Func<T, Maybe<TOther>>, Func<T, TOther, TResult>)

Allows values from multiple maybe instances to be combined in the select portion of a LINQ query.

SelectNonempty<T, TResult>(IEnumerable<Maybe<T>>, Func<T, Maybe<TResult>>)

Converts an of Maybe<T> values to a set of Maybe{TResult} values, skipping any empty values.

ToNullable<T>(Maybe<T>)

Returns a from a Maybe<T> where null is used if the maybe instance is empty.

ValueOr<T>(Maybe<T>, T)

Returns the value of the Maybe{T} instance if it is non-empty, otherwise returns value.

ValueOr<T>(Maybe<T>, Func<T>)

Returns the value of the Maybe{T} instance if it is non-empty, otherwise returns the result of the valueFactory function.

ValueOrException<T>(Maybe<T>, Exception)

Returns the value of source if it is not empty, otherwise throws the provided exception.

ValueOrException<T>(Maybe<T>, Func<Exception>)

Returns the value of source if it is not empty, otherwise throws an exception created from the function provided.

WhenNothing<T>(Maybe<T>, Action)

Exectues the action only if source is empty.

WhenSomething<T>(Maybe<T>, Action<T>)

Executes the action is this instance is not nothing.

Where<T>(Maybe<T>, Func<T, Boolean>)

Extension method allowing Maybe{T} instances to be used in LINQ where clauses.

Back to top Copyright (c) 2017 Troy Willmot