public static Option <T> ToOption <T>(this IExceptional <T> obj) { return(obj.Match(Some, _ => None)); }
/// <summary> /// Init using a single exceptional. /// </summary> public Exceptional(IExceptional myIExceptional) : this() { PushIExceptional(myIExceptional); }
public static IExceptional <TResultOut> SelectMany <TResultIn, TResultBind, TResultOut>(this IExceptional <TResultIn> first, Func <TResultIn, IExceptional <TResultBind> > func, Func <TResultIn, TResultBind, TResultOut> select) { return(first.Bind(aval => func(aval) .Bind(bval => select(aval, bval) .ToExceptional()))); }
/// <summary> /// Adds the given exceptional. /// </summary> public Exceptional PushIExceptional(IExceptional myIExceptional) { lock (this) { // Add warnings... if (myIExceptional.IWarnings != null && myIExceptional.IWarnings.Any()) foreach (var _Warning in myIExceptional.IWarnings.ToList().Reverse<IWarning>()) _IWarnings.Push(_Warning); // Add errors... if (myIExceptional.IErrors != null && myIExceptional.IErrors.Any()) foreach (var _Error in myIExceptional.IErrors.ToList().Reverse<IError>()) _IErrors.Push(_Error); return this; } }
public static IExceptional <TResultOut> Bind <TResultIn, TResultOut>(this IExceptional <TResultIn> first, Func <TResultIn, IExceptional <TResultOut> > func) { return(first.IsException() ? ((IInternalException)first).Copy <TResultOut>() : func(first.Value())); }