public override async Task OnExecuting(DispatchingContext context) { await Task.CompletedTask; Console.WriteLine($"MESSAGE TYPE : {context.MessageInstance.GetType()}"); Console.WriteLine($"MESSAGE INSTANCE : {JsonConvert.SerializeObject(context.MessageInstance)}"); Console.WriteLine($"HANDLER TYPE : {context.HandlerInstance.GetType()}"); }
protected static async Task Execute(DispatchingContext context, Func<object, Task> action) { await context.With(c => c.MessageInstance) .If( message => message.GetType() .GetInterfaces() .Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IQueryFor<>))) .Do(action); }
public abstract Task OnException(DispatchingContext context);
public abstract Task OnExecuted(DispatchingContext context);
async Task IContextInterceptor.OnException(DispatchingContext context, Exception invocationException) { await Execute(context, message => OnException(context)); }
async Task IContextInterceptor.OnExecuted(DispatchingContext context) { await Execute(context, message => OnExecuted(context)); }
public override async Task OnException(DispatchingContext context) { await Task.CompletedTask; }
public override async Task OnExecuted(DispatchingContext context) { await Task.CompletedTask; Console.WriteLine($"RESULT: {JsonConvert.SerializeObject(context.Result)}"); Console.WriteLine(); }
public async Task OnException(DispatchingContext context, Exception invocationException) { await Task.CompletedTask; }