private static NetRPCContext CreateContext(string request) { var context = new NetRPCContext(); context.RequestString = request; return(context); }
private object[] DeserializeParameters(NetRPCContext context) { if (context.Request.Parameters == null) { return(null); } return(context.Request.Parameters.Select(p => serializer.DeserializeParameter(p)).ToArray()); }
private void Serialize(NetRPCContext context) { context.Response.Error = context.Error; context.Response.Result = serializer.SerializeToParameter(context.Result); var serializedResponse = serializer.SerializeResponse(context.Response); context.ResponseString = serializedResponse; }
private void InitializeResponse(NetRPCContext context) { context.Response = new Response { CallId = context.Request.CallId, SessionId = context.Request.SessionId, Version = Constants.Version, Method = context.Request.Method, Headers = new Dictionary <string, string>() }; }
private void Deserialize(NetRPCContext context) { try { context.Request = serializer.DeserializeRequest(context.RequestString); context.Parameters = DeserializeParameters(context); InitializeResponse(context); } catch (Exception ex) { throw new NetRPCException(300, ex.Message, ex); } }
private void Dispatch(NetRPCContext context) { var serviceInstance = serviceFactory.Create(new OperationContext(context)); try { var result = invoker.Dispatch(contract, context.Request.Method, serviceInstance, context.Parameters); context.Result = result; } catch (Exception ex) { context.Error = new Error { Code = 300, Description = ex.Message }; throw; } finally { serviceFactory.Release(serviceInstance); } }
public OperationContext(NetRPCContext ctx) { current = ctx; }