Example #1
0
        public Result <TResult> Send <TResult>(ICommand <TResult> command)             //Send a Command
        {
            var result = new Result <TResult>();

            try {
                var plan = new MediatorPlan <TResult>(typeof(ICommandHandler <,>), "Handle", command.GetType(), _dependencyResolver);
                result.Data = plan.Invoke(command);
            }
            catch (Exception e) {
                result.Exception = e;
            }

            return(result);
        }
Example #2
0
        public async Task <Response <TResponse> > RequestAsync <TResponse>(IAsyncRequest <TResponse> query)
        {
            var response = new Response <TResponse>();

            try {
                var plan = new MediatorPlan <TResponse>(typeof(IAsyncRequestHandler <,>), "HandleAsync", query.GetType(), _dependencyResolver);

                response.Data = await plan.InvokeAsync(query);
            }
            catch (Exception e) {
                response.Exception = e;
            }

            return(response);
        }
Example #3
0
        public virtual Response <TResponse> Request <TResponse>(IRequest <TResponse> request)
        {
            var response = new Response <TResponse>();

            try {
                var plan = new MediatorPlan <TResponse>(typeof(IRequestHandler <,>), "Handle", request.GetType(), _dependencyResolver);
                response.Data = plan.Invoke(request);
            }
            catch (Exception e) {
                response.Exception = e;
            }



            return(response);
        }