Auto Generate for Tab File: "Example.bytes" Singleton class for less memory use
Inheritance: TableRowParser
コード例 #1
0
ファイル: AppSettings.cs プロジェクト: dingzheng8866/GEngine
        /// <summary>
        /// Do reload the setting file: Example
        /// </summary>
        void _ReloadAll(bool throwWhenDuplicatePrimaryKey, string customContent = null)
        {
            for (var j = 0; j < TabFilePaths.Length; j++)
            {
                var       tabFilePath = TabFilePaths[j];
                TableFile tableFile;
                if (customContent == null)
                {
                    tableFile = SettingModule.Get(tabFilePath, false);
                }
                else
                {
                    tableFile = TableFile.LoadFromString(customContent);
                }

                using (tableFile)
                {
                    foreach (var row in tableFile)
                    {
                        var            pk = ExampleSetting.ParsePrimaryKey(row);
                        ExampleSetting setting;
                        if (!_dict.TryGetValue(pk, out setting))
                        {
                            setting           = new ExampleSetting(row);
                            _dict[setting.Id] = setting;
                        }
                        else
                        {
                            if (throwWhenDuplicatePrimaryKey)
                            {
                                throw new System.Exception(string.Format("DuplicateKey, Class: {0}, File: {1}, Key: {2}", this.GetType().Name, tabFilePath, pk));
                            }
                            else
                            {
                                setting.Reload(row);
                            }
                        }
                    }
                }
            }

            if (OnReload != null)
            {
                OnReload();
            }

            ReloadCount++;
            Log.Info("Reload settings: {0}, Row Count: {1}, Reload Count: {2}", GetType(), Count, ReloadCount);
        }
コード例 #2
0
        /// <summary>
        /// Do reload the setting file: Example
        /// </summary>
        void _ReloadAll(bool throwWhenDuplicatePrimaryKey)
        {
            for (var j = 0; j < TabFilePaths.Length; j++)
            {
                var tabFilePath = TabFilePaths[j];
                using (var tableFile = SettingModule.Get(tabFilePath, false))
                {
                    foreach (var row in tableFile)
                    {
                        var            pk = ExampleSetting.ParsePrimaryKey(row);
                        ExampleSetting setting;
                        if (!_dict.TryGetValue(pk, out setting))
                        {
                            setting           = new ExampleSetting(row);
                            _dict[setting.Id] = setting;
                        }
                        else
                        {
                            if (throwWhenDuplicatePrimaryKey)
                            {
                                throw new System.Exception(string.Format("DuplicateKey, Class: {0}, File: {1}, Key: {2}", this.GetType().Name, tabFilePath, pk));
                            }
                            else
                            {
                                setting.Reload(row);
                            }
                        }
                    }
                }
            }

            if (OnReload != null)
            {
                OnReload();
            }
        }
コード例 #3
0
ファイル: AppSettings.cs プロジェクト: mr-kelly/KEngine
        /// <summary>
        /// Do reload the setting file: Example
        /// </summary>
	    void _ReloadAll(bool throwWhenDuplicatePrimaryKey)
        {
            for (var j = 0; j < TabFilePaths.Length; j++)
            {
                var tabFilePath = TabFilePaths[j];
                using (var tableFile = SettingModule.Get(tabFilePath, false))
                {
                    foreach (var row in tableFile)
                    {
                        var pk = ExampleSetting.ParsePrimaryKey(row);
                        ExampleSetting setting;
                        if (!_dict.TryGetValue(pk, out setting))
                        {
                            setting = new ExampleSetting(row);
                            _dict[setting.Id] = setting;
                        }
                        else 
                        {
                            if (throwWhenDuplicatePrimaryKey) throw new System.Exception(string.Format("DuplicateKey, Class: {0}, File: {1}, Key: {2}", this.GetType().Name, tabFilePath, pk));
                            else setting.Reload(row);
                        }
                    }
                }
            }

	        if (OnReload != null)
	        {
	            OnReload();
	        }
        }