protected async Task ExecuteAction(MethodInfo method, MessageController target, Message message, OperationContext ctx) { IEnumerable <IFilter> filters = GetFilters(method); object func = null; if ((func = WrapAction(method, target, message)) != null) { Action <ActionContext> action = func as Action <ActionContext>; if (filters != null) { foreach (IFilter item in filters) { action = WrapFilter(action, item); } } ActionContext a_ctx = new ActionContext(target, method, message, ctx); action(a_ctx); ctx.AddResult(a_ctx.Results); } else if ((func = WrapActionAsync(method, target, message)) != null) { Func <ActionContext, Task> action = func as Func <ActionContext, Task>; if (filters != null) { foreach (IFilter item in filters) { action = WrapFilterAsync(action, item); } } ActionContext a_ctx = new ActionContext(target, method, message, ctx); await action(a_ctx); ctx.AddResult(a_ctx.Results); } else { throw new Exception(); //TODO: decide which exception } }