예제 #1
0
        public object ToData(ChaosInvocationResp resp)
        {
            if (resp.Exception != null)
            {
                throw new RemotingException(resp.Exception);
            }

            if (string.IsNullOrEmpty(resp.DataTypeFullName))
            {
                return(null);
            }

            if (resp.Data == null)
            {
                return(null);
            }

            if (resp.Data.Length <= 0)
            {
                return(null);
            }

            var dataType = _typeFinder.Find(resp.DataTypeFullName);

            return(_serializer.Deserialize(dataType, resp.Data));
        }
예제 #2
0
        private ChaosInvocationResp ToChaosInvocationResp(ChaosInvocation invocation,
                                                          object returnValue)
        {
            var invocationReply = new ChaosInvocationResp()
            {
                DataTypeFullName = invocation.ReturnTypeFullName
            };

            if (invocation.IsReturnTask)
            {
                var taskResult = returnValue.GetTaskResult();
                invocationReply.Data = _serializer.Serialize(taskResult.value);
            }
            else
            {
                invocationReply.Data = _serializer.Serialize(returnValue);
            }

            return(invocationReply);
        }
예제 #3
0
 private void ClientOnOnMessage(object sender, MessageEventArgs e)
 {
     _reply = (ChaosInvocationResp)_binarySerializer.Deserialize(typeof(ChaosInvocationResp), e.RawData);
     _singal.Set();
 }