Beispiel #1
0
 public void PushObject(object obj, string keyName = null)
 {
     if (mIsTxtMode)
     {
         mContext = StringSerialize.Serialize(obj);
     }
     else
     {
         if (string.IsNullOrEmpty(keyName))
         {
             keyName = obj.GetType().Name;
         }
         BytesPack pack = null;
         if (mIsBinary)
         {
             pack = BytesSerialize.Serialize(obj);
         }
         else
         {
             string temps = StringSerialize.Serialize(obj);
             pack = new BytesPack();
             pack.CreateReadBytes(System.Text.Encoding.UTF8.GetBytes(temps));
         }
         mDataPacks[keyName] = pack;
     }
 }
Beispiel #2
0
        //拷贝复制
        public static T CopyData <T>(T obj)
        {
            var pack = BytesSerialize.Serialize(obj);

            return((T)BytesSerialize.Deserialize <T>(pack));
        }