コード例 #1
0
 private void WriteCompletionMessage(CompletionMessage message, JsonTextWriter writer)
 {
     WriteInvocationId(message, writer);
     if (!string.IsNullOrEmpty(message.Error))
     {
         writer.WritePropertyName(ErrorPropertyName);
         writer.WriteValue(message.Error);
     }
     else if (message.HasResult)
     {
         writer.WritePropertyName(ResultPropertyName);
         PayloadSerializer.Serialize(writer, message.Result);
     }
 }
コード例 #2
0
 private void WriteCompletionMessage(CompletionMessage message, JsonTextWriter writer)
 {
     writer.WriteStartObject();
     WriteHubInvocationMessageCommon(message, writer, HubProtocolConstants.CompletionMessageType);
     if (!string.IsNullOrEmpty(message.Error))
     {
         writer.WritePropertyName(ErrorPropertyName);
         writer.WriteValue(message.Error);
     }
     else if (message.HasResult)
     {
         writer.WritePropertyName(ResultPropertyName);
         _payloadSerializer.Serialize(writer, message.Result);
     }
     writer.WriteEndObject();
 }
コード例 #3
0
        private void WriteCompletionMessage(CompletionMessage completionMessage, Packer packer)
        {
            var resultKind =
                completionMessage.Error != null ? ErrorResult :
                completionMessage.HasResult ? NonVoidResult :
                VoidResult;

            packer.PackArrayHeader(3 + (resultKind != VoidResult ? 1 : 0));
            packer.Pack(CompletionMessageType);
            packer.PackString(completionMessage.InvocationId);
            packer.Pack(resultKind);
            switch (resultKind)
            {
            case ErrorResult:
                packer.PackString(completionMessage.Error);
                break;

            case NonVoidResult:
                packer.PackObject(completionMessage.Result, _serializationContext);
                break;
            }
        }
コード例 #4
0
        private void WriteCompletionMessage(CompletionMessage message, Packer packer)
        {
            var resultKind =
                message.Error != null ? ErrorResult :
                message.HasResult ? NonVoidResult :
                VoidResult;

            packer.PackArrayHeader(4 + (resultKind != VoidResult ? 1 : 0));
            packer.Pack(HubProtocolConstants.CompletionMessageType);
            PackHeaders(packer, message.Headers);
            packer.PackString(message.InvocationId);
            packer.Pack(resultKind);
            switch (resultKind)
            {
            case ErrorResult:
                packer.PackString(message.Error);
                break;

            case NonVoidResult:
                packer.PackObject(message.Result, SerializationContext);
                break;
            }
        }