示例#1
0
        /// <summary>
        /// 从元数据转换为第三方客户数据
        /// </summary>
        /// <param name="attribute">当前字段标注的属性</param>
        /// <param name="data">元数据</param>
        /// <returns>
        /// 返回转换后的第三方客户数据
        /// </returns>
        /// <exception cref="N:KJFramework.Exception">转换失败</exception>
        public override object Process(IntellectPropertyAttribute attribute, byte[] data)
        {
            TransactionIdentityTypes identityType = (TransactionIdentityTypes)data[0];

            if (identityType == TransactionIdentityTypes.TCP)
            {
                return(TCPTransactionIdentity.Deserialize(data, 0, data.Length));
            }
            if (identityType == TransactionIdentityTypes.NamedPipe)
            {
                return(NamedPipeTransactionIdentity.Deserialize(data, 0, data.Length));
            }
            throw new NotSupportedException(string.Format("#We were not support current type of Transaction-Identity yet! {0}", identityType));
        }
示例#2
0
        /// <summary>
        ///     从元数据转换为第三方客户数据
        /// </summary>
        /// <param name="instance">目标对象</param>
        /// <param name="result">分析结果</param>
        /// <param name="data">元数据</param>
        /// <param name="offset">元数据所在的偏移量</param>
        /// <param name="length">元数据长度</param>
        public override void Process(object instance, GetObjectAnalyseResult result, byte[] data, int offset, int length = 0)
        {
            TransactionIdentityTypes identityType = (TransactionIdentityTypes)data[offset];

            if (identityType == TransactionIdentityTypes.TCP)
            {
                result.SetValue(instance, TCPTransactionIdentity.Deserialize(data, offset, length));
            }
            else if (identityType == TransactionIdentityTypes.NamedPipe)
            {
                result.SetValue(instance, NamedPipeTransactionIdentity.Deserialize(data, offset, length));
            }
            else
            {
                throw new NotSupportedException(string.Format("#We were not support current type of Transaction-Identity yet! {0}", identityType));
            }
        }
 /// <summary>
 ///     TransactionIdentity类型存储的静态构造器
 /// </summary>
 static TransactionIdentityValueStored()
 {
     _instance        = ValueStoredHelper.BuildMethod <TransactionIdentity>();
     _toBytesDelegate = delegate(IMemorySegmentProxy proxy, BaseValueStored messageIdentityValueStored)
     {
         TransactionIdentity identity = messageIdentityValueStored.GetValue <TransactionIdentity>();
         if (identity.IdentityType == TransactionIdentityTypes.TCP)
         {
             TCPTransactionIdentity.Serialize(0, IdentitySerializationTypes.Metadata, (TCPTransactionIdentity)identity, proxy);
         }
         else if (identity.IdentityType == TransactionIdentityTypes.NamedPipe)
         {
             NamedPipeTransactionIdentity.Serialize(0, IdentitySerializationTypes.Metadata, (NamedPipeTransactionIdentity)identity, proxy);
         }
         else
         {
             throw new NotSupportedException(string.Format("#We were not support current type of Transaction-Identity yet! {0}", identity.IdentityType));
         }
     };
     _toDataDelegate = delegate(ResourceBlock metadataObject, byte id, byte[] byteData, int offsetStart, uint offsetLength)
     {
         TransactionIdentityTypes identityType = (TransactionIdentityTypes)byteData[offsetStart];
         if (identityType == TransactionIdentityTypes.TCP)
         {
             metadataObject.SetAttribute(id, new TransactionIdentityValueStored(TCPTransactionIdentity.Deserialize(byteData, offsetStart, (int)offsetLength)));
         }
         else if (identityType == TransactionIdentityTypes.NamedPipe)
         {
             metadataObject.SetAttribute(id, new TransactionIdentityValueStored(NamedPipeTransactionIdentity.Deserialize(byteData, offsetStart, (int)offsetLength)));
         }
         else
         {
             throw new NotSupportedException(string.Format("#We were not support current type of Transaction-Identity yet! {0}", identityType));
         }
     };
 }