Exemple #1
0
        private void VisitedDeserialize(
            DeserializeData Data,
            Action <object> Set,
            SerializeInfo deserializer)
        {
            if (deserializer.ConstantSize > -1)
            {
                Set(deserializer.Deserializer(Data));
                return;
            }
            var LastFrom = Data.From;
            var Fr       = BitConverter.ToInt32(Data.Data, LastFrom);

            Data.From += 4;
            if (deserializer.CanStoreInVisit == false)
            {
                if (Fr == -2)
                {
                    return;
                }
                Set(deserializer.Deserializer(Data));
                return;
            }
            ObjectContainer VisitedObj;

            switch (Fr)
            {
            case -1:
                VisitedObj = new ObjectContainer()
                {
                    HashCode         = LastFrom,
                    IsUniqueHashCode = true
                };
                Data.Visitor.Add(VisitedObj);
                VisitedObj.obj = deserializer.Deserializer(Data);
                Set(VisitedObj.obj);
                return;

            case -2:
                return;
            }
            VisitedObj = new ObjectContainer()
            {
                HashCode         = Fr,
                IsUniqueHashCode = true
            };
            Data.Visitor.TryGetValue(VisitedObj, out VisitedObj);
            if (VisitedObj.obj == null)
            {
                Data.AtLast += () => Set(VisitedObj.obj);
            }
            else
            {
                Set(VisitedObj.obj);
            }
        }
        private void VisitedDeserialize(
            Action <object> Set,
            SerializeInfo deserializer)
        {
            var LastFrom = From;
            var Fr       = BitConverter.ToInt32(D_Data, From);

            From += 4;
            if (deserializer.CanStoreInVisit == false)
            {
                if (Fr == -2)
                {
                    return;
                }
                Set(deserializer.Deserializer());
                return;
            }
            ObjectContainer VisitedObj;

            switch (Fr)
            {
            case -1:
                VisitedObj = new ObjectContainer()
                {
                    ObjHashCode = LastFrom
                };
                Visitor.BinaryInsert(VisitedObj);
                VisitedObj.obj = deserializer.Deserializer();
                Set(VisitedObj.obj);
                return;

            case -2:
                return;
            }
            VisitedObj = new ObjectContainer()
            {
                ObjHashCode = Fr
            };
            VisitedObj = Visitor.BinarySearch(VisitedObj).Value;
            if (VisitedObj.obj == null)
            {
                AtLast += () => Set(VisitedObj.obj);
            }
            else
            {
                Set(VisitedObj.obj);
            }
        }