public void Respond(KayakContext context, Action<Exception> callback) { try { var invocationInfo = (InvocationInfo)context.Items[InvocationInfoContextKey]; var invocation = new KayakInvocation(context, invocationInfo); // TODO :Ferhat bunu da ben ekledim. invocation.Context.Activator.AddInstances(_Instances); bool cancel = RaiseInvoking(invocation); if (cancel) callback(null); else { AddBindersAndHandlers(invocation); invocation.InvokeWithCallback(e => { RaiseInvoked(invocation, e); callback(e); }); } } catch (Exception e) { callback(e); } }
internal InvokingEventArgs(KayakInvocation invocation) : base(invocation) { }
public InvalidMethodResponse(KayakInvocation c) { context = c; }
internal InvokedEventArgs(KayakInvocation invocation, Exception e) : base(invocation) { Exception = e; }
internal InvocationEventArgs(KayakInvocation invocation) { Invocation = invocation; }
bool RaiseInvoking(KayakInvocation invocation) { var result = false; if (Invoking != null) { var args = new InvokingEventArgs(invocation); Invoking(this, args); result = args.CancelInvocation; } return result; }
void RaiseInvoked(KayakInvocation invocation, Exception e) { if (Invoked != null) { var args = new InvokedEventArgs(invocation, e); Invoked(this, args); } }
void AddBindersAndHandlers(KayakInvocation invocation) { invocation.Binders.Add(ParameterBinder); if (RequestBodyAttribute.IsDefinedOnParameters(invocation.Info.Method)) invocation.Binders.Add(JsonDeserializer); if (invocation.Info.Method.ReturnType != typeof(void)) invocation.Handlers.Add(JsonSerializer); }