コード例 #1
0
        public IInvocationMessage DeserializeInvocationMessage(IPooledBuffer message)
        {
            using (var envelope = InvocationMessageEnvelope.Rent())
            {
                envelope.MergeFrom(message);
                switch (envelope.PayloadCase)
                {
                case InvocationMessageEnvelope.PayloadOneofCase.Message:
                    return(_messageFactory.CreateInvocationMessageHeader());

                case InvocationMessageEnvelope.PayloadOneofCase.Confirmation:
                    return(_messageFactory.CreateInvocationMessageReceived());

                case InvocationMessageEnvelope.PayloadOneofCase.SendCompletion:
                    return(_messageFactory.CreateInvocationSendCompletion());

                default:
                    throw new InvalidOperationException($"Unexpected payload case: {envelope.PayloadCase}");
                }
            }
        }