예제 #1
0
        //反序列化
        public override void Deserialize(IoBuffer stream)
        {
            _value = stream.ReadStr();
#if SERIALIZE_DEBUG
            SerializeUtil.AddLog(this);
#endif
        }
예제 #2
0
        //反序列化
        public override void Deserialize(IoBuffer stream)
        {
            int changeCount = stream.ReadInt32();

#if SERIALIZE_DEBUG
            SerializeUtil.BeginParentLog(this, changeCount, false);
#endif
            for (int i = 0; i < changeCount; ++i)
            {
                enSerializeChangeType type = (enSerializeChangeType)stream.ReadByte();
                string key = "";
                if (type != enSerializeChangeType.clear)
                {
                    key = stream.ReadStr();
                }
#if SERIALIZE_DEBUG
                SerializeUtil.BeginChangeLog(i, type, key);
#endif
                if (type == enSerializeChangeType.add)
                {
                    T item = (T)Activator.CreateInstance(typeof(T));
                    item.Parent = this;
                    item.Key    = key;
                    item.Deserialize(stream);
                    _dict[item.Key] = item;
                }
                else if (type == enSerializeChangeType.remove)
                {
                    if (!_dict.Remove(key))
                    {
                        Debuger.LogError("同步失败");
                    }
                }
                else if (type == enSerializeChangeType.change)
                {
                    T item = _dict.Get(key);
                    if (item == null)
                    {
                        Debuger.LogError("同步失败2");
                    }
                    item.Deserialize(stream);
                }
                else if (type == enSerializeChangeType.clear)
                {
                    _dict.Clear();
                }
#if SERIALIZE_DEBUG
                SerializeUtil.EndChangeLog();
#endif
            }
#if SERIALIZE_DEBUG
            SerializeUtil.EndParentLog(this);
#endif
        }
예제 #3
0
        //反序列化
        public override void Deserialize(IoBuffer stream)
        {
            enType t = (enType)stream.ReadByte();

            SetType(t);
            if (_type == enType.Bool)
            {
                _value = stream.ReadBool();
            }
            else if (_type == enType.Byte)
            {
                _value = stream.ReadByte();
            }
            else if (_type == enType.Short)
            {
                _value = stream.ReadInt16();
            }
            else if (_type == enType.Int)
            {
                _value = stream.ReadInt32();
            }
            else if (_type == enType.Long)
            {
                _value = stream.ReadInt64();
            }
            else if (_type == enType.Float)
            {
                _value = stream.ReadFloat();
            }
            else if (_type == enType.Double)
            {
                _value = stream.ReadDouble();
            }
            else if (_type == enType.String)
            {
                _value = stream.ReadStr();
            }
            else
            {
                Debuger.LogError("未知的类型");
            }
#if SERIALIZE_DEBUG
            SerializeUtil.AddLog(this);
#endif
        }