Ejemplo n.º 1
0
 /// <summary>
 ///   序列化当前事务唯一标示
 /// </summary>
 /// <param name="id">如果是以智能对象的方式进行序列化,则此ID为标签ID</param>
 /// <param name="serializationType">序列化方式</param>
 /// <param name="identity">被序列化的事务唯一标示</param>
 /// <param name="proxy">内存片段代理器</param>
 public static void Serialize(byte id, IdentitySerializationTypes serializationType, TCPTransactionIdentity identity, IMemorySegmentProxy proxy)
 {
     if (serializationType == IdentitySerializationTypes.IntellectObject)
     {
         //writes attribute id.
         proxy.WriteByte(id);
         //writes TCP transaction identity total length.
         proxy.WriteInt32(19);
     }
     proxy.WriteByte((byte)identity.IdentityType);
     proxy.WriteByte((byte)(identity.IsRequest ? 1 : 0));
     proxy.WriteByte((byte)(identity.IsOneway ? 1 : 0));
     proxy.WriteIPEndPoint((IPEndPoint)identity.EndPoint);
     proxy.WriteUInt32(identity.MessageId);
 }
 /// <summary>
 ///   序列化当前事务唯一标示
 /// </summary>
 /// <param name="id">如果是以智能对象的方式进行序列化,则此ID为标签ID</param>
 /// <param name="serializationType">序列化方式</param>
 /// <param name="identity">被序列化的事务唯一标示</param>
 /// <param name="proxy">内存片段代理器</param>
 public static void Serialize(byte id, IdentitySerializationTypes serializationType, NamedPipeTransactionIdentity identity, IMemorySegmentProxy proxy)
 {
     if (serializationType == IdentitySerializationTypes.IntellectObject)
     {
         //writes attribute id.
         proxy.WriteByte(id);
         //writes NamedPipe transaction identity total length.
         proxy.WriteInt32(15);
     }
     proxy.WriteByte((byte)identity.IdentityType);
     proxy.WriteByte((byte)(identity.IsRequest ? 1 : 0));
     proxy.WriteByte((byte)(identity.IsOneway ? 1 : 0));
     proxy.WriteUInt64(((NamedPipeEndPoint)identity.EndPoint).GetPipeCodeId());
     proxy.WriteUInt32(identity.MessageId);
 }