Пример #1
0
        public ProtoBufferTransportMessage(TransportMessage transportMessage)
        {
            Id = transportMessage.Id;
            ContentType = transportMessage.ContentType;

            object contentObject;
            if (transportMessage.IsInvokeMessage())
            {
                contentObject = new ProtoBufferRemoteInvokeMessage(transportMessage.GetContent<RemoteInvokeMessage>());
            }
            else if (transportMessage.IsInvokeResultMessage())
            {
                contentObject = new ProtoBufferRemoteInvokeResultMessage(transportMessage.GetContent<RemoteInvokeResultMessage>());
            }
            else
            {
                throw new NotSupportedException($"无法支持的消息类型:{ContentType}!");
            }

            Content = SerializerUtilitys.Serialize(contentObject);
        }
Пример #2
0
        public ProtoBufferTransportMessage(TransportMessage transportMessage)
        {
            Id          = transportMessage.Id;
            ContentType = transportMessage.ContentType;

            object contentObject;

            if (transportMessage.IsInvokeMessage())
            {
                contentObject = new ProtoBufferRemoteInvokeMessage(transportMessage.GetContent <RemoteInvokeMessage>());
            }
            else if (transportMessage.IsInvokeResultMessage())
            {
                contentObject = new ProtoBufferRemoteInvokeResultMessage(transportMessage.GetContent <RemoteInvokeResultMessage>());
            }
            else
            {
                throw new NotSupportedException($"无法支持的消息类型:{ContentType}!");
            }

            Content = SerializerUtilitys.Serialize(contentObject);
        }