public static T SetResponse <T>(this XenMessageContext ctx, Action <T> action = null) where T : Response, new() { var response = XenMessage.Create <T>(); ctx.Response = response; action?.Invoke(response); return((T)ctx.Response); }
public static T SetRequest <T>(this XenMessageContext ctx, Action <T> action = null) where T : Request, new() { var request = XenMessage.Create <T>(); ctx.Request = request; action?.Invoke(request); return((T)ctx.Request); }
public static T Get <T>(this XenMessageContext ctx) where T : XenMessage { var request = ctx.Request as T; if (request != null) { return(request); } var response = ctx.Response as T; return(response); }