Esempio n. 1
0
        private fsResult InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, ref object result, out List <fsObjectProcessor> processors)
        {
            // We handle object references first because we could be
            // deserializing a cyclic type that is inherited. If that is the
            // case, then if we handle references after inheritances we will try
            // to create an object instance for an abstract/interface type.

            // While object construction should technically be two-pass, we can
            // do it in one pass because of how serialization happens. We
            // traverse the serialization graph in the same order during
            // serialization and deserialization, so the first time we encounter
            // an object it'll always be the definition. Any times after that it
            // will be a reference. Because of this, if we encounter a reference
            // then we will have *always* already encountered the definition for
            // it.
            if (IsObjectReference(data))
            {
                var refId = int.Parse(data.AsDictionary[Key_ObjectReference].AsString);
                result     = _references.GetReferenceObject(refId);
                processors = GetProcessors(result.GetType());
                return(fsResult.Success);
            }

            return(InternalDeserialize_2_Version(overrideConverterType, data, storageType, ref result, out processors));
        }
Esempio n. 2
0
        private fsResult InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, ref object result, out List <fsObjectProcessor> processors)
        {
            // We handle object references first because we could be
            // deserializing a cyclic type that is inherited. If that is the
            // case, then if we handle references after inheritances we will try
            // to create an object instance for an abstract/interface type.

            // First check to see if this is a Unity object. If so, we need to look up the reference in
            // the list provided to us by the caller.
            if (IsUnityObjectReference(data))
            {
                if (_unityReferences.Enabled)
                {
                    int refId = (int)data.AsDictionary[Key_UnityObjectReference].AsInt64;
                    result     = _unityReferences.GetUnityObject(refId);
                    processors = GetProcessors(null);
                    return(fsResult.Success);
                }
                else
                {
                    result     = null;
                    processors = GetProcessors(null);
                    return(fsResult.Fail("Data was serialized with UnityReferences but none were provided for deserialization"));
                }
            }

            // While object construction should technically be two-pass, we can
            // do it in one pass because of how serialization happens. We
            // traverse the serialization graph in the same order during
            // serialization and deserialization, so the first time we encounter
            // an object it'll always be the definition. Any times after that it
            // will be a reference. Because of this, if we encounter a reference
            // then we will have *always* already encountered the definition for
            // it.
            if (IsObjectReference(data))
            {
                int refId = int.Parse(data.AsDictionary[Key_ObjectReference].AsString);
                result     = _references.GetReferenceObject(refId);
                processors = GetProcessors(result.GetType());
                return(fsResult.Success);
            }

            return(InternalDeserialize_2_Version(overrideConverterType, data, storageType, ref result, out processors));
        }
Esempio n. 3
0
        private fsResult InternalDeserialize_1_CycleReference(fsData data, Type storageType, ref object result)
        {
            // We handle object references first because we could be deserializing a cyclic type that is
            // inherited. If that is the case, then if we handle references after inheritances we will try
            // to create an object instance for an abstract/interface type.

            // While object construction should technically be two-pass, we can do it in
            // one pass because of how serialization happens. We traverse the serialization
            // graph in the same order during serialization and deserialization, so the first
            // time we encounter an object it'll always be the definition. Any times after that
            // it will be a reference. Because of this, if we encounter a reference then we
            // will have *always* already encountered the definition for it.
            if (IsObjectReference(data))
            {
                int refId = int.Parse(data.AsDictionary[Key_ObjectReference].AsString);
                result = _references.GetReferenceObject(refId);
                return(fsResult.Success);
            }

            return(InternalDeserialize_2_Version(data, storageType, ref result));
        }
Esempio n. 4
0
        private fsResult InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, ref object result, out List <fsObjectProcessor> processors)
        {
            // We handle object references first because we could be deserializing a cyclic type that is
            // inherited. If that is the case, then if we handle references after inheritances we will try
            // to create an object instance for an abstract/interface type.
            //継承された循環型を逆シリアル化することができるので、最初にオブジェクト参照を処理します。 その場合、継承の後に参照を処理する場合、抽象/インタフェース型のオブジェクトインスタンスを作成しようとします。

            // While object construction should technically be two-pass, we can do it in
            // one pass because of how serialization happens. We traverse the serialization
            // graph in the same order during serialization and deserialization, so the first
            // time we encounter an object it'll always be the definition. Any times after that
            // it will be a reference. Because of this, if we encounter a reference then we
            // will have *always* already encountered the definition for it.
            // オブジェクトの構築は技術的には2パスでなければならないが、シリアライゼーションの仕組みのために1パスで行うことができる。 シリアライゼーションとデシリアライゼーションでは、シリアライゼーショングラフを同じ順序でトラバースします。最初にオブジェクトに遭遇したときには常にその定義になります。 それ以降はいつでも参考になります。 このため、参照に遭遇した場合は、*常に*定義済みです。
            if (IsObjectReference(data))
            {
                int refId = int.Parse(data.AsDictionary[Key_ObjectReference].AsString);
                result     = _references.GetReferenceObject(refId);
                processors = GetProcessors(result.GetType());
                return(fsResult.Success);
            }

            return(InternalDeserialize_2_Version(overrideConverterType, data, storageType, ref result, out processors));
        }