コード例 #1
0
        ProcessTransportMessage <TTransportMessage, TDomainMessage>(
            ITransportToDomainMessageTransform <TTransportMessage,
                                                TDomainMessage> messageTransform,
            ServiceProvider rootServiceProvider,
            IIocManagement <TTransportMessage> iocManagement,
            TTransportMessage transportMessage)
        {
            Option <TDomainMessage> domainMessageO =
                messageTransform.ToDomainMessage(transportMessage);

            OptionAsync <Either <IPipelineError, Tuple <TTransportMessage, TDomainMessage> > > result2 =
                domainMessageO.MapAsync(d =>
                                        HandleDomainMessage(
                                            rootServiceProvider,
                                            iocManagement,
                                            transportMessage,
                                            d));

            Task <Either <
                      IPipelineError,
                      Tuple <TTransportMessage, TDomainMessage> > >
            res = result2.Match(
                sm => sm,
                () => Prelude.Left((IPipelineError) new ErrorParsingTransportMessage()));

            return(res);
        }
コード例 #2
0
 public static async Task ShouldBeSome <T>(this OptionAsync <T> @this, Action <T> someValidation = null) =>
 await @this.Match(Some : someValidation ?? Common.Noop, None : Common.ThrowIfNone);
コード例 #3
0
 public static async Task ShouldBeNone <T>(this OptionAsync <T> @this) =>
 await @this.Match(Some : Common.ThrowIfSome, None : Common.SuccessfulNone);
コード例 #4
0
 /// <summary>
 /// By default, Some case is converted to 200 OK and None is 404.
 /// Optionally, provide functions to handle Some and None cases.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="option"></param>
 /// <returns></returns>
 public static Task <IActionResult> ToActionResult <T>(this OptionAsync <T> option, Func <T, IActionResult> some = null, Func <IActionResult> none = null) =>
 option.Match(some ?? Ok, none ?? NotFound);
コード例 #5
0
 /// <summary>
 /// Some case is converted to Ok JsonResult. None case is 404.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="option"></param>
 /// <returns></returns>
 public static Task <IActionResult> ToActionResult <T>(this OptionAsync <T> option) =>
 option.Match(Ok, NotFound);
コード例 #6
0
 /// <summary>
 /// Converts a <see cref="OptionAsync{A}"/> to an <see cref="IActionResult"/>.
 /// Default some case conversion will convert units to NoContent and all other values to Ok.
 /// Default none case conversion will convert to a NotFound.
 /// </summary>
 /// <typeparam name="A">The <see cref="OptionAsync{A}"/> parameter type.</typeparam>
 /// <param name="this">The <see cref="OptionAsync{A}"/> to convert to an <see cref="IActionResult"/>.</param>
 /// <param name="Some">Optionally, a custom conversion for the some case.</param>
 /// <param name="None">Optionally, a custom conversion for the none case.</param>
 /// <returns>An <see cref="IActionResult"/> which can be returned from a controller.</returns>
 public static Task <IActionResult> ToActionResult <A>(this OptionAsync <A> @this, Func <A, IActionResult> Some = null, Func <IActionResult> None = null) =>
 @this.Match(Some: Some ?? GetGenericSuccessResult, None: None ?? GetNotFoundResult);
コード例 #7
0
ファイル: FOptionAsync.cs プロジェクト: ykhadas/language-ext
 public OptionAsync <B> BiMap(OptionAsync <A> ma, Func <A, B> fa, Func <Unit, B> fb) =>
 new OptionAsync <B>(OptionDataAsync.Lazy <B>(async() =>
                                              await ma.Match(
                                                  Some: x => fa(x),
                                                  None: () => fb(unit))));
コード例 #8
0
 public static Task <IActionResult> ToActionResult <TA>(this OptionAsync <TA> self, Func <TA, IActionResult> some = null, Func <IActionResult> none = null) =>
 self.Match(Some: some ?? GetGenericSuccessResult, None: none ?? GetNotFoundResult);