private DEventNotificationHandler CreateGeneralizedMessageHandler(IAppletChannel channel) { var handlerResolverByIntent = GetMethodInfosByIntentLookup() .ToDictionary( item => item.Key, item => new MessageHandlerFactory( this, item.ToArray(), ProcessUnmappedMessageAsync)); Task RoutedProcessOneAsync(IDeliveryArgs args, CancellationToken cancellation) { if (handlerResolverByIntent.TryGetValue(args.IntentId, out var router)) { var handler = router.GetHandler(args.Dto) ?? throw new NullReferenceException( $"{nameof(router)}.{nameof(router.GetHandler)} returned null"); cancellation.ThrowIfCancellationRequested(); return(handler.Invoke(args, cancellation)); } return(ProcessUnmappedMessageAsync(args, cancellation)); } return(RoutedProcessOneAsync); }
protected DeliveryArgs(byte[] body, IAppletChannel channel) { Body = body ?? throw new ArgumentNullException(nameof(body)); Channel = channel ?? throw new ArgumentNullException(nameof(channel)); _appInfo = Channel.GetAppInfo() ?? throw new NullReferenceException($"{nameof(channel)}.{nameof(Channel.GetAppInfo)} returned null"); }
protected DeliveryArgs(DispatchArgs dispatchArgs, IAppletChannel channel) { if (dispatchArgs == null) { throw new ArgumentNullException(nameof(dispatchArgs)); } Body = dispatchArgs.Body ?? throw new NullReferenceException(nameof(dispatchArgs.Body)); Channel = channel ?? throw new ArgumentNullException(nameof(channel)); _appInfo = Channel.GetAppInfo() ?? throw new NullReferenceException($"{nameof(channel)}.{nameof(Channel.GetAppInfo)} returned null"); IntentId = dispatchArgs.IntentId; CorrelationId = dispatchArgs.CorrelationId; From = dispatchArgs.From; DataContractId = dispatchArgs.DataContractId; AppletId = dispatchArgs.AppletId; }
public async Task <T> FanInAsync(IAppletChannel channel, IFanInPolicy <T> policy = null) { if (channel == null) { throw new ArgumentNullException(nameof(channel)); } policy ??= FanInPolicy.FirstInWins <T>(); await channel .GetResponses(this) .TakeWhile(reply => !policy.TryCompleteWith(reply)) .LastOrDefaultAsync() .Timeout(policy.Timeout); Debug.Assert(policy.HasResult); return(policy.Result); }
public InMemoryDeliveryArgs(DispatchArgs dispatchArgs, IAppletChannel channel) : base(dispatchArgs, channel) { }
protected AppletDeliveryProcessor(IAppletChannel channel) { Channel = channel ?? throw new ArgumentNullException(nameof(channel)); _generalizedMessageHandler = CreateGeneralizedMessageHandler(channel); }