Esempio n. 1
0
        EnumerableConverter InitializeNew(Type type)
        {
            var info = new InitializeInfo(type, CurrentGenerator);

            var converter = new EnumerableConverter();

            converter.Initialize(info);

            return(converter);
        }
Esempio n. 2
0
        public override uint Initialize(InitializeInfo info)
        {
            if (_info.Type != ArrayType.Unknown)
            {
                return(0);
            }

            Type?elemType = info.Type.GetElementType();

            PopulateTypeInfo(ref _info, info.GetMap(elemType !), info.Type);
            return(0);
        }
Esempio n. 3
0
        public override uint Initialize(InitializeInfo info)
        {
            TypeCode typeCode = Type.GetTypeCode(info.Type);

            // IntPtr
            if (typeCode == TypeCode.Object)
            {
                throw new Exception("Unsupported primitive provided. Please note that ABSave does not currently support .NET 5 and above types.");
            }

            _typeCode = (PrimitiveType)typeCode;
            return(0);
        }
Esempio n. 4
0
        public override uint Initialize(InitializeInfo info)
        {
            // Try to handle any immediately recognizable types (such as List<> or any direct interfaces).
            if (TryHandleDirectTypes(info, info.Type))
            {
                return(0);
            }

            // Work out what category this type falls under.
            CollectionCategory category = DetectCollectionType(info.Type.GetInterfaces(), out Type elementOrKeyType, out Type? valueType);

            SetStateFromCategory(info, category, elementOrKeyType, valueType);
            return(0);
        }
Esempio n. 5
0
 public override void InitGCloud(InitializeInfo cloudInfo)
 {
     MSDKLogin.LoginRetEvent        += OnLoginRetEvent;
     MSDKLogin.LoginBaseRetEvent    += OnLoginBaseRetEvent;
     MSDKNotice.NoticeRetEvent      += OnNoticeRetEvent;
     MSDKPush.PushBaseRetEvent      += OnPushBaseRetEvent;
     MSDKPush.PushNotificationEvent += OnPushNotificationEvent;
     MSDKCrash.CrashBaseRetEvent    += OnCrashBaseRetEvent;
     IGCloud.Instance.Initialize(cloudInfo);
     RegisterDirCallback();
     inited = true;
     MSDKPush.RegisterPush("XG");
     MSDKReport.Init("Beacon,TDM");
     MSDK.Init();
 }
Esempio n. 6
0
        public override (VersionInfo?, bool) GetVersionInfo(InitializeInfo info, uint version)
        {
            ObjectMemberSharedInfo[]? members = _hasOneVersion ?
                                                ObjectVersionMapper.GenerateForOneVersion(this, info._gen) :
                                                ObjectVersionMapper.GenerateNewVersion(this, info._gen, version);

            SaveBaseMembersAttribute?attr = MappingHelpers.FindAttributeForVersion(_intermediateInfo.BaseMemberAttributes !, version);

            // If there is base for this version, get the converter for it.
            ObjectConverter?baseConv = null;

            if (attr != null)
            {
                baseConv = GetBaseObjectConverter(info, attr);
            }

            return(new ObjectVersionInfo(members, baseConv), true);
        }
Esempio n. 7
0
        ObjectConverter GetBaseObjectConverter(InitializeInfo info, SaveBaseMembersAttribute attr)
        {
            if (!info.Type.IsSubclassOf(attr.BaseType))
            {
                throw new InvalidSaveBaseMembersException($"The type {info.Type.Name} has an attribute on it saying that ABSave should serialize the base members {attr.BaseType.Name}, but the type doesn't inherit from this type anywhere in its inheritance chain! The attribute must describe a base type of the class.");
            }

            // We'll try and get the map.
            // If what it gives back isn't an "ObjectConverter" or it threw "UnserializedTypeException",
            // then this object clearly ISN'T a "SaveMembers" type like it should be and as such we'll fail.
            try
            {
                var map = info.GetMap(attr.BaseType);
                if (map.Converter is ObjectConverter converter)
                {
                    return(converter);
                }
            }
            catch (UnserializableTypeException) { }

            throw new InvalidSaveBaseMembersException($"The type {info.Type.Name} has an attribute on it saying that ABSave should serialize the base members {attr.BaseType.Name}, but this type doesn't have the 'SaveMembers' attribute on it, and it must for ABSave to serialize its members too.");
        }
Esempio n. 8
0
        /// <summary>
        /// 在Init(HonorSDKGameObject gameObject, OnFinish<ResultInit> initListener, string gameResVersion, Dictionary<string, string> configs = null)初始化成功后调用
        /// 初始化游戏云
        /// 初始化TDir
        /// <see cref="https://sdk.gcloud.tencent.com/documents/details/%E5%8C%BA%E6%9C%8D%E5%AF%BC%E8%88%AA%20Maple/%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97/%E5%8C%BA%E6%9C%8D%E5%AF%BC%E8%88%AA%EF%BC%88Dir%E6%9C%8D%E5%8A%A1%EF%BC%89"/>
        /// </summary>
        /// <param name="cloudInfo"></param>
        /// <param name="tdirInfo"></param>

        public virtual void InitGCloud(InitializeInfo cloudInfo)
        {
        }
Esempio n. 9
0
 public override (VersionInfo, bool) GetVersionInfo(InitializeInfo info, uint version) => (null, _writesToHeader);
Esempio n. 10
0
 /// <summary>
 /// Gets information that can be used by the converter and varies depending on the version number in the source.
 /// This info will be cached and may be used across many threads so ensure it does not change once created.
 /// </summary>
 public virtual (VersionInfo?, bool) GetVersionInfo(InitializeInfo info, uint version) => (null, false);
Esempio n. 11
0
 /// <summary>
 /// Initializes a given converter for a given type.
 /// </summary>
 public virtual uint Initialize(InitializeInfo info) => 0;
Esempio n. 12
0
 public override uint Initialize(InitializeInfo info)
 {
     return(IntermediateMapper.CreateIntermediateObjectInfo(info.Type, _saveMode, out _intermediateInfo));
 }