// Token: 0x06000462 RID: 1122 RVA: 0x0001C2A0 File Offset: 0x0001A4A0
        public override fsResult TryDeserialize(fsData storage, ref object instance, Type storageType)
        {
            fsResult fsResult = fsResult.Success;

            if (fsPrimitiveConverter.UseBool(storageType))
            {
                fsResult fsResult2;
                fsResult = (fsResult2 = fsResult + base.CheckType(storage, fsDataType.Boolean));
                if (fsResult2.Succeeded)
                {
                    instance = storage.AsBool;
                }
                return(fsResult);
            }
            if (fsPrimitiveConverter.UseDouble(storageType) || fsPrimitiveConverter.UseInt64(storageType))
            {
                if (storage.IsDouble)
                {
                    instance = Convert.ChangeType(storage.AsDouble, storageType);
                }
                else if (storage.IsInt64)
                {
                    instance = Convert.ChangeType(storage.AsInt64, storageType);
                }
                else
                {
                    if (!this.Serializer.Config.Serialize64BitIntegerAsString || !storage.IsString || (storageType != typeof(long) && storageType != typeof(ulong)))
                    {
                        return(fsResult.Fail(string.Concat(new object[]
                        {
                            base.GetType().Name,
                            " expected number but got ",
                            storage.Type,
                            " in ",
                            storage
                        })));
                    }
                    instance = Convert.ChangeType(storage.AsString, storageType);
                }
                return(fsResult.Success);
            }
            if (fsPrimitiveConverter.UseString(storageType))
            {
                fsResult fsResult3;
                fsResult = (fsResult3 = fsResult + base.CheckType(storage, fsDataType.String));
                if (fsResult3.Succeeded)
                {
                    instance = storage.AsString;
                }
                return(fsResult);
            }
            return(fsResult.Fail(base.GetType().Name + ": Bad data; expected bool, number, string, but got " + storage));
        }
            public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType)
            {
                fsResult fsResult   = fsResult.Success;
                var      gameObject = instance as GameObject;

                if (!gameObject)
                {
                    return(fsResult += fsResult.Fail("GameObject is not instantiated."));
                }
                if ((fsResult += CheckType(data, fsDataType.Object)).Failed)
                {
                    return(fsResult);
                }
                return(fsResult += DeserializeImportedComponents(data, gameObject, Serializer.Context.Get <Mod>()));
            }
            private fsResult DeserializeImportedComponents(fsData fsData, GameObject gameObject, Mod mod)
            {
                fsResult fsResult = fsResult.Success;

                if ((fsResult += CheckType(fsData, fsDataType.Object)).Failed)
                {
                    return(fsResult);
                }
                Dictionary <string, fsData> dict = fsData.AsDictionary;

                // Restore components on this gameobject
                fsData components;

                if ((fsResult += CheckKey(dict, "Components", out components)).Failed)
                {
                    return(fsResult);
                }
                if (!components.IsNull)
                {
                    if ((fsResult += CheckType(components, fsDataType.Array)).Failed)
                    {
                        return(fsResult);
                    }
                    foreach (fsData componentData in components.AsList)
                    {
                        // Get type name
                        string typeName;
                        if ((fsResult += DeserializeMember(componentData.AsDictionary, null, "$type", out typeName)).Failed)
                        {
                            return(fsResult);
                        }

                        // Add component and deserialize
                        Type type = FindType(mod, typeName);
                        if (type == null)
                        {
                            return(fsResult += fsResult.Fail(string.Format("Failed to find type {0}.", typeName)));
                        }
                        object instance = gameObject.AddComponent(type);
                        if ((fsResult += fsSerializer.TryDeserialize(componentData, type, ref instance)).Failed)
                        {
                            return(fsResult);
                        }
                    }
                }

                // Restore components on children
                fsData children;

                if ((fsResult += CheckKey(dict, "Children", out children)).Failed)
                {
                    return(fsResult);
                }
                if (!children.IsNull)
                {
                    if ((fsResult += CheckType(children, fsDataType.Object)).Failed)
                    {
                        return(fsResult);
                    }
                    foreach (KeyValuePair <string, fsData> childData in children.AsDictionary)
                    {
                        Transform child = gameObject.transform.Find(childData.Key);
                        if (child == null)
                        {
                            return(fsResult += fsResult.Fail(string.Format("{0} not found on {1}", childData.Key, gameObject.name)));
                        }
                        if ((fsResult += DeserializeImportedComponents(childData.Value, child.gameObject, mod)).Failed)
                        {
                            return(fsResult);
                        }
                    }
                }

                return(fsResult);
            }