Esempio n. 1
0
        private object _GetObject(object obj, System.Type type, string keyName)
        {
            if (mIsTxtMode)
            {
                if (obj == null)
                {
                    return(StringSerialize.Deserialize(mContext, type));
                }
                else
                {
                    StringSerialize.Deserialize(mContext, obj);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(keyName))
                {
                    keyName = type.Name;
                }

                BytesPack pack = null;
                if (mDataPacks.TryGetValue(keyName, out pack))
                {
                    if (mIsBinary)
                    {
                        if (obj == null)
                        {
                            return(BytesSerialize.Deserialize(pack, type));
                        }
                        else
                        {
                            BytesSerialize.Deserialize(pack, obj);
                        }
                    }
                    else
                    {
                        string str = System.Text.Encoding.UTF8.GetString(pack.GetStream());
                        if (obj == null)
                        {
                            return(StringSerialize.Deserialize(str, type));
                        }
                        else
                        {
                            StringSerialize.Deserialize(str, obj);
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 2
0
        //拷贝复制
        public static T CopyData <T>(T obj)
        {
            var pack = BytesSerialize.Serialize(obj);

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