/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } string mmsg = streamer.ReadFixedString(); if (mmsg != MessageContext.QPRO) { throw new Exception("Incorrect message format"); } Mode = (CoverMode)streamer.ReadValue <byte>(); IsTrans = streamer.ReadValue <bool>(); MaxRetry = streamer.ReadValue <byte>(); QueueName = streamer.ReadString(); ServerPath = streamer.ReadString(); //Cover = streamer.ReadValue<QCover>(); ConnectTimeout = streamer.ReadValue <int>(); TargetPath = streamer.ReadString(); IsTopic = streamer.ReadValue <bool>(); CommitMode = (PersistCommitMode)streamer.ReadValue <byte>(); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } string mmsg = streamer.ReadFixedString(); if (mmsg != TcpReplyStream.MsgReplyBegin) { throw new Exception("Incorrect message format"); } m_ReplyCode = streamer.ReadValue <int>(); m_ReplyType = (TcpReplyType)streamer.ReadValue <byte>(); if (m_ReplyType == TcpReplyType.Stream) { m_ReplyStream = (NetStream)streamer.ReadValue(); } else { m_Text = streamer.ReadString(); } string endmsg = streamer.ReadFixedString(); if (endmsg != TcpReplyStream.MsgReplyEnd) { throw new Exception("Incorrect message format"); } }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } Identifier = streamer.ReadString();//.ReadValue<Guid>(); ItemState = (TransItemState)streamer.ReadValue <int>(); Retry = streamer.ReadValue <int>(); ArrivedTime = streamer.ReadValue <DateTime>(); Timeout = TimeSpan.FromSeconds(streamer.ReadValue <int>()); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } HostName = streamer.ReadString(); ServerName = streamer.ReadString(); _RawHostAddress = streamer.ReadString(); _HostAddress = streamer.ReadString(); _HostProtocol = (HostProtocol)streamer.ReadValue <byte>(); }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteString(Identifier);//.WriteValue(Identifier); streamer.WriteValue((int)ItemState); streamer.WriteValue(Retry); streamer.WriteValue(ArrivedTime); streamer.WriteValue(Timeout); streamer.Flush(); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public override void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } Version = streamer.ReadValue <int>(); var MessageState = (MessageState)streamer.ReadValue <byte>(); var MessageType = (MQTypes)streamer.ReadValue <byte>(); QCommand = (QueueCmd)streamer.ReadValue <byte>(); Priority = (Priority)streamer.ReadValue <byte>(); Identifier = streamer.ReadString();//.ReadValue<Guid>(); var Retry = streamer.ReadValue <byte>(); var ArrivedTime = streamer.ReadValue <DateTime>(); Creation = streamer.ReadValue <DateTime>(); Modified = streamer.ReadValue <DateTime>(); var Duration = streamer.ReadValue <int>(); TransformType = (TransformType)streamer.ReadValue <byte>(); DuplexType = (DuplexTypes)streamer.ReadValue <byte>(); Expiration = streamer.ReadValue <int>(); Host = streamer.ReadString(); Label = streamer.ReadString(); Sender = streamer.ReadString(); BodyStream = (NetStream)streamer.ReadValue(); TypeName = streamer.ReadString(); /* * Version = streamer.ReadValue<int>(); * var MessageType = (MQTypes)streamer.ReadValue<byte>(); * QCommand = (QueueCmd)streamer.ReadValue<byte>(); * Priority = (Priority)streamer.ReadValue<byte>(); * Identifier = streamer.ReadString();//.ReadValue<Guid>(); * Creation = streamer.ReadValue<DateTime>(); * //TransformType = (TransformTypes)streamer.ReadValue<byte>(); * TransformType = (TransformType)streamer.ReadValue<byte>(); * DuplexType = (DuplexTypes)streamer.ReadValue<byte>(); * Expiration = streamer.ReadValue<int>(); * * Host = streamer.ReadString(); * //Sender = streamer.ReadString(); * BodyStream = (NetStream)streamer.ReadValue(); * //_TypeName = streamer.ReadString(); */ }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteString(HostName); streamer.WriteString(ServerName); streamer.WriteString(RawHostAddress); streamer.WriteString(HostAddress); streamer.WriteValue((byte)Protocol); streamer.Flush(); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } MessageState = (MessageState)streamer.ReadValue <byte>(); MessageType = (MQTypes)streamer.ReadValue <byte>(); Command = (QueueCmd)streamer.ReadValue <byte>(); Priority = (Priority)streamer.ReadValue <byte>(); Identifier = streamer.ReadString();//.ReadValue<Guid>(); Retry = streamer.ReadValue <byte>(); ArrivedTime = streamer.ReadValue <DateTime>(); //SentTime = streamer.ReadValue<DateTime>(); Modified = streamer.ReadValue <DateTime>(); Expiration = streamer.ReadValue <int>(); //MessageId = streamer.ReadValue<int>(); TransformType = (TransformTypes)streamer.ReadValue <byte>(); Destination = streamer.ReadString(); //Label = streamer.ReadString(); //Sender = streamer.ReadString(); ////Topic = streamer.ReadString(); //HeaderStream = (NetStream)streamer.ReadValue(); m_BodyStream = (NetStream)streamer.ReadValue(); //var ns = (NetStream)streamer.ReadValue(); //Body = ns.ToArray(); ItemBinary = streamer.ReadValue <byte[]>(); //var map = streamer.GetMapper(); //Console.WriteLine(map); //if (Command != QueueCmd.Ack) //{ // Formatter = (Formatters)streamer.ReadValue<int>(); // m_BodyStream = (NetStream)streamer.ReadValue(); // _TypeName = streamer.ReadString(); // Segments = streamer.ReadValue<byte>(); // //HostType = streamer.ReadValue<byte>(); // Notify = streamer.ReadString(); // //Command = streamer.ReadString(); // //IsDuplex = streamer.ReadValue<bool>(); // //HeaderStream = (GenericNameValue)streamer.ReadValue(); //} }
/* * /// <summary> * /// Release all resources. * /// </summary> * public void Dispose() * { * Dispose(true); * GC.SuppressFinalize(this); * } * bool disposed = false; * /// <summary> * /// Get indicate wether the current instance is Disposed. * /// </summary> * internal bool IsDisposed * { * get { return disposed; } * } * /// <summary> * /// Dispose. * /// </summary> * /// <param name="disposing"></param> * internal void Dispose(bool disposing) * { * if (!disposed) * { * //Command = null; * * Host = null; * } * disposed = true; * } */ #endregion #region ISerialEntity /// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public override void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } //streamer.WriteValue(ToBinary()); streamer.WriteValue(Version); streamer.WriteValue((byte)MessageState.Sending); streamer.WriteValue((byte)MessageType); streamer.WriteValue((byte)QCommand); streamer.WriteValue((byte)Priority); streamer.WriteString(Identifier); //.WriteValue(ItemId); streamer.WriteValue((byte)0); //Retry streamer.WriteValue(Modified); // ArrivedTime); streamer.WriteValue(Creation); streamer.WriteValue(Modified); streamer.WriteValue((int)0);// Duration); streamer.WriteValue((byte)TransformType); streamer.WriteValue((byte)DuplexType); streamer.WriteValue(Expiration); streamer.WriteString(Host); streamer.WriteString(Label); streamer.WriteString(Sender); streamer.WriteValue(BodyStream); streamer.WriteString(TypeName); /* * streamer.WriteValue(Version); * streamer.WriteValue((byte)MessageType); * streamer.WriteValue((byte)QCommand); * streamer.WriteValue((byte)Priority); * streamer.WriteString(Identifier);//.WriteValue(ItemId); * streamer.WriteValue(Creation); * streamer.WriteValue((byte)TransformType); * streamer.WriteValue((byte)DuplexType); * streamer.WriteValue(Expiration); * * streamer.WriteString(Host); * //streamer.WriteString(Sender); * * streamer.WriteValue(BodyStream); * //streamer.WriteString(TypeName); */ }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteFixedString(MessageContext.QPTR, 4); streamer.WriteValue((byte)State); streamer.WriteValue((int)Retry); streamer.WriteString(Identifier); streamer.WriteString(Host); streamer.WriteValue(ArrivedTime); streamer.WriteValue(TimeOut); //streamer.WriteString(Location); streamer.Flush(); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } MessageState = (MessageState)streamer.ReadValue <byte>(); Identifier = streamer.ReadString(); Creation = streamer.ReadValue <DateTime>(); Host = streamer.ReadString(); Label = streamer.ReadString(); Duration = streamer.ReadValue <int>(); Count = streamer.ReadValue <int>(); //string arrived = streamer.ReadString(); //ArrivedTime= Types.ToNullableDate(arrived); ArrivedTime = streamer.ReadValue <DateTime>(); }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteFixedString(MessageContext.QPRO, 4); streamer.WriteValue((byte)Mode); streamer.WriteValue(IsTrans); streamer.WriteValue(MaxRetry); streamer.WriteValue(QueueName); streamer.WriteValue(ServerPath); //streamer.WriteValue(Cover); streamer.WriteValue(ConnectTimeout); streamer.WriteValue(CoverPath); streamer.Flush(); }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteValue((byte)MessageState); streamer.WriteValue((byte)MessageType); streamer.WriteValue((byte)Command); streamer.WriteValue((byte)Priority); streamer.WriteString(Identifier);//.WriteValue(ItemId); streamer.WriteValue(Retry); streamer.WriteValue(ArrivedTime); //streamer.WriteValue(SentTime); streamer.WriteValue(Modified); streamer.WriteValue(Expiration); //streamer.WriteValue(MessageId); streamer.WriteValue((byte)TransformType); streamer.WriteString(Destination); streamer.WriteValue(BodyStream); //streamer.WriteString(Label); //streamer.WriteString(Sender); //streamer.WriteString(Topic); //streamer.WriteValue(HeaderStream); //streamer.WriteValue(new NetStream(Body)); streamer.WriteValue(ItemBinary); //if (Command != QueueCmd.Ack) //{ // streamer.WriteValue((int)Formatter); // streamer.WriteValue(BodyStream); // streamer.WriteString(TypeName); // streamer.WriteValue(Segments); // streamer.WriteString(Notify); //} streamer.Flush(); }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteValue((byte)MessageState); streamer.WriteString(Identifier); streamer.WriteValue(Creation); streamer.WriteString(Host); streamer.WriteString(Label); streamer.WriteValue(Duration); streamer.WriteValue(Count); streamer.WriteValue(ArrivedTime); //string arrived = ArrivedTime == null || ArrivedTime.HasValue == false ? null : ArrivedTime.ToString(); //streamer.WriteString(arrived); streamer.Flush(); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } MessageState = (MessageState)streamer.ReadValue <byte>(); MessageType = (MQTypes)streamer.ReadValue <byte>(); Command = (QueueCmd)streamer.ReadValue <byte>(); Priority = (Priority)streamer.ReadValue <byte>(); Identifier = streamer.ReadString(); //.ReadValue<Guid>(); Retry = streamer.ReadValue <byte>(); ArrivedTime = streamer.ReadValue <DateTime>(); Creation = streamer.ReadValue <DateTime>(); Modified = streamer.ReadValue <DateTime>(); Duration = streamer.ReadValue <int>(); TransformType = (TransformTypes)streamer.ReadValue <byte>(); Host = streamer.ReadString(); Sender = streamer.ReadString(); Label = streamer.ReadString(); }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteFixedString(TcpReplyStream.MsgReplyBegin, 4); streamer.WriteValue((int)ReplyCode); streamer.WriteValue((byte)m_ReplyType); if (m_ReplyType == TcpReplyType.Stream) { streamer.WriteValue(m_ReplyStream); } else { streamer.WriteString(m_Text); } streamer.WriteFixedString(TcpReplyStream.MsgReplyEnd, 5); streamer.Flush(); }
/// <summary> /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityRead(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } string mmsg = streamer.ReadFixedString(); if (mmsg != MessageContext.QPTR) { throw new Exception("Incorrect message format"); } m_State = (PtrState)streamer.ReadValue <byte>(); m_Retry = streamer.ReadValue <int>(); m_Identifier = streamer.ReadString(); m_Host = streamer.ReadString(); m_ArrivedTime = streamer.ReadValue <DateTime>(); m_TimeOut = streamer.ReadValue <int>(); //m_Location = streamer.ReadString(); }
/// <summary> /// Write the current object include the body and properties to stream using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public void EntityWrite(Stream stream, IBinaryStreamer streamer) { if (streamer == null) { streamer = new BinaryStreamer(stream); } streamer.WriteValue((byte)MessageState); streamer.WriteValue((byte)MessageType); streamer.WriteValue((byte)Command); streamer.WriteValue((byte)Priority); streamer.WriteString(Identifier); //.WriteValue(ItemId); streamer.WriteValue(Retry); streamer.WriteValue(ArrivedTime); streamer.WriteValue(Creation); streamer.WriteValue(Modified); streamer.WriteValue(Duration); streamer.WriteValue((byte)TransformType); streamer.WriteString(Host); streamer.WriteString(Sender); streamer.WriteString(Label); streamer.Flush(); }
/// <summary> /// Initialize a new instance of MessageStream from stream using for <see cref="ISerialEntity"/>. /// </summary> /// <param name="stream"></param> /// <param name="streamer"></param> public Message(Stream stream, IBinaryStreamer streamer) { EntityRead(stream, streamer); }