Esempio n. 1
0
        /// <summary>
        /// Assembles the StreamMetadataBody object from byte array
        /// </summary>
        /// <param name="reader">BinaryReader to deserialize from</param>
        /// <returns>StreamMetadataBody object</returns>
        public StreamMetadataBody Read(BinaryReader reader)
        {
            var metadataKind          = (StreamMetadataKind)reader.ReadInt32();
            StreamMetadataBody result = null;

            switch (metadataKind)
            {
            case StreamMetadataKind.ReceiveSequenceNumber:
            case StreamMetadataKind.SendSequenceNumber:
            case StreamMetadataKind.DeleteSequenceNumber:
                result = StreamSequenceNumber.FromByteArray(reader);
                break;

            case StreamMetadataKind.OutboundStableParameters:
                result = OutboundStreamStableParameters.FromByteArray(reader);
                break;

            case StreamMetadataKind.InboundStableParameters:
                result = InboundStreamStableParameters.FromByteArray(reader);
                break;

            default:
                Diagnostics.Assert(false, "Unknown Stream MetadataKind in StreamMetadataBody.FromByteArray()");
                break;
            }

            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Converts the OutboundStreamStableParameters to byte array
 /// </summary>
 /// <returns>Byte array</returns>
 public void ToByteArray(OutboundStreamStableParameters value, BinaryWriter writer)
 {
     try
     {
         value.WriteBaseParameters(writer);
         writer.Write(value.MessageQuota);
         writer.Write((int)value.AcceptanceResponse);
     }
     catch (Exception e)
     {
         Tracing.WriteExceptionAsError("OutboundStreamStableParameters.ToByteArray", e, "Content: {0}", this);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Copy constructor used for updates to avoid in memory update that would change "committed" state in the store before commit
        /// especially when the object is acquired through Get
        /// </summary>
        /// <param name="stableParameters"></param>
        internal OutboundStreamStableParameters(OutboundStreamStableParameters stableParameters)
        {
            // Init base parameters
            this.InitializeBaseParameters(
                StreamMetadataKind.OutboundStableParameters,
                stableParameters.StreamName,
                stableParameters.PartnerId,
                stableParameters.CurrentState,
                stableParameters.CloseMessageSequenceNumber);

            this.AcceptanceResponse = stableParameters.AcceptanceResponse;
            this.MessageQuota       = stableParameters.MessageQuota;
        }
Esempio n. 4
0
        /// <summary>
        /// Assembles the OutboundStreamStableParameters object from byte array
        /// </summary>
        /// <param name="reader">BinaryReader to deserialize from</param>
        /// <returns>OutboundStreamStableParameters object</returns>
        public static OutboundStreamStableParameters FromByteArray(BinaryReader reader)
        {
            var result = new OutboundStreamStableParameters();

            var cursor = 0;

            result.ReadBaseParameters(reader);
            Diagnostics.Assert(
                result.MetadataKind == StreamMetadataKind.OutboundStableParameters,
                "Unexpected StreamMetadataType when decoding OutboundStreamStableParameters.FromByteArray");

            result.MessageQuota = reader.ReadInt32();
            Diagnostics.Assert(result.MessageQuota > 0, "Non-positive message quota found when decoding OutboundStreamStableParameters.FromByteArray");
            cursor += sizeof(int);

            result.AcceptanceResponse = (StreamWireProtocolResponse)reader.ReadInt32();

            return(result);
        }