private async Task <TResponse> DoRequestAsync <TRequest, TResponse>(IDomainRequest <TRequest, TResponse> request, ILifetimeScope lifetimeScope) where TRequest : IDomainRequest <TRequest, TResponse> where TResponse : IDomainResponse { var foundHandlers = GetRequestHandlers(request.GetType()).ToList(); if (foundHandlers.Any()) { foreach (var handler in foundHandlers) { var response = ExecuteRequestHandler(request, handler, lifetimeScope); if (response != null) { return(response); } } } foundHandlers = GetAsyncEventHandlers(request.GetType()).ToList(); if (foundHandlers.Any()) { foreach (var handler in foundHandlers) { var response = await ExecuteRequestHandlerAsync(request, handler, lifetimeScope).ConfigureAwait(continueOnCapturedContext: false); if (response != null) { return(response); } } } return(default(TResponse)); }
public async Task <IEnumerable <TResponse> > DoMulticastRequestAsync <TRequest, TResponse>(IDomainRequest <TRequest, TResponse> request, ILifetimeScope lifetimeScope) where TRequest : IDomainRequest <TRequest, TResponse> where TResponse : IDomainResponse { var responses = new List <TResponse>(); var foundHandlers = GetRequestHandlers(request.GetType()).ToList(); if (foundHandlers.Any()) { foreach (var handler in foundHandlers) { var response = ExecuteRequestHandler(request, handler, lifetimeScope); if (response != null) { responses.Add(response); } } } foundHandlers = GetAsyncEventHandlers(request.GetType()).ToList(); if (foundHandlers.Any()) { foreach (var handler in foundHandlers) { var response = await ExecuteRequestHandlerAsync(request, handler, lifetimeScope).ConfigureAwait(continueOnCapturedContext: false); if (response != null) { responses.Add(response); } } } return(responses); }
public static IDomainResponse Dispatch(IDomainRequest request) { return(_Handlers[request.GetType()](request)); }
public static T Dispatch <T>(IDomainRequest request) where T : IDomainResponse { return((T)_Handlers[request.GetType()](request)); }