Пример #1
0
        private static NetRPCContext CreateContext(string request)
        {
            var context = new NetRPCContext();

            context.RequestString = request;
            return(context);
        }
Пример #2
0
 private object[] DeserializeParameters(NetRPCContext context)
 {
     if (context.Request.Parameters == null)
     {
         return(null);
     }
     return(context.Request.Parameters.Select(p => serializer.DeserializeParameter(p)).ToArray());
 }
Пример #3
0
        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;
        }
Пример #4
0
 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>()
     };
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
        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);
            }
        }
Пример #7
0
 public OperationContext(NetRPCContext ctx)
 {
     current = ctx;
 }