Ejemplo n.º 1
0
 /// <summary>
 /// Returns value of the option if it has value. If not, returns value created by the otherwise function.
 /// </summary>
 public static B GetOrElse <A, B>(this IOption <A> option, Func <Unit, B> otherwise)
     where A : B
 {
     if (option.NonEmpty)
     {
         return(option.GetOrDefault());
     }
     return(otherwise(Unit.Value));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns value of the option if it has value. If not, returns the <paramref name="otherwise"/>.
 /// </summary>
 public static B GetOrElse <A, B>(this IOption <A> option, B otherwise)
     where A : B
 {
     if (option.NonEmpty)
     {
         return(option.GetOrDefault());
     }
     return(otherwise);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns value of the option if it has value. If not, returns false.
 /// </summary>
 public static bool GetOrFalse(this IOption <bool> option)
 {
     return(option.GetOrDefault());
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns value of the option if it has value. If not, returns zero.
 /// </summary>
 public static decimal GetOrZero(this IOption <decimal> option)
 {
     return(option.GetOrDefault());
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns value of the option if it has value. If not, returns zero.
 /// </summary>
 public static int GetOrZero(this IOption <int> option)
 {
     return(option.GetOrDefault());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns value of the option if it has value. If not, returns null.
 /// </summary>
 public static A GetOrNull <A>(this IOption <A> option)
     where A : class
 {
     return(option.GetOrDefault());
 }
Ejemplo n.º 7
0
 public IndexerArgument(IOption <IdentifierExpression> id, ExpressionSyntax value)
 {
     this.Identifier = id.GetOrDefault();
     this.Value      = value;
 }
Ejemplo n.º 8
0
 public RangeExpressionSyntax(IOption <ExpressionSyntax> e1, IOption <ExpressionSyntax> e2)
 {
     this.S1 = e1.GetOrDefault();
     this.S2 = e2.GetOrDefault();
 }