/// <summary> /// Assembles the stream name key object from byte array /// </summary> /// <param name="reader">BinaryReader to deserialize from</param> /// <returns>Stream name key object</returns> public StreamNameKey Read(BinaryReader reader) { var encoder = new StringEncoder(); // Decode Service stream name var streamName = new Uri(encoder.Decode(reader)); // Decode Partner info var partnerId = PartitionKey.Decode(reader); return(new StreamNameKey(streamName, partnerId)); }
internal InboundOpenStreamName(InboundBaseStreamWireMessage inboundBaseMessage) { Diagnostics.Assert( inboundBaseMessage.Kind == StreamWireProtocolMessageKind.OpenStream, "Wrong kind of InboundBaseStreamWireMessage used to construct InboundOpenStreamName"); Diagnostics.Assert( inboundBaseMessage.Payload != null, "null streamName payload in InboundBaseStreamWireMessage used to construct InboundOpenStreamName"); var encoder = new StringEncoder(); var reader = new BinaryReader(new MemoryStream(inboundBaseMessage.Payload)); this.StreamName = new Uri(encoder.Decode(reader)); Diagnostics.Assert(reader.PeekChar() == -1, "streamName payload in InboundBaseStreamWireMessage contains more than streamName"); }
/// <summary> /// Read BaseStreamMetadataBody from Memory Stream /// </summary> /// <param name="reader">BinaryReader to deserialize from</param> protected void ReadBaseParameters(BinaryReader reader) { this.MetadataKind = (StreamMetadataKind)reader.ReadInt32(); this.CurrentState = (PersistentStreamState)reader.ReadInt32(); this.CurrentStateDate = DateTime.FromBinary(reader.ReadInt64()); this.CloseMessageSequenceNumber = reader.ReadInt64(); var encoder = new StringEncoder(); this.StreamName = new Uri(encoder.Decode(reader)); this.PartnerId = PartitionKey.Decode(reader); this.BaseEncodeLength = (sizeof(int) * 2) + (sizeof(long) * 2) + encoder.EncodingByteCount + this.PartnerId.EncodingByteCount; }