Exemplo n.º 1
0
        public void Init()
        {
            var catalog = new Catalog();

            using (var db = dbConnectionFactory.OpenDbConnection())
            {
                db.CreateTableIfNotExists <TestConfig>();
                db.CreateTableIfNotExists <KeyValueTestConfig>();

                for (int i = 0; i < 100000; i++)
                {
                    var t = catalog.CreateInstance <TestConfig>();
                    t.Id = i + 1;
                    t.Lv = i % 5;

                    db.Insert(t);
                }

                for (int i = 0; i < 100000; i++)
                {
                    var kvconfig = new KeyValueTestConfig()
                    {
                        Id    = $"ID_{i + 1}",
                        Value = $"V_{i + 1}"
                    };

                    db.Insert(kvconfig);
                }
            }
        }
Exemplo n.º 2
0
        public IEnumerable <T> LoadConfigData <T>() where T : IConfigEntity
        {
            var catalog = new Catalog();

            List <T> list = new List <T>();

            if (typeof(T).IsAssignableFrom(typeof(TestConfig)))
            {
                for (int i = 0; i < 100000; i++)
                {
                    var t = catalog.CreateInstance <TestConfig>();
                    t.Id = i + 1;
                    t.Lv = i % 5;

                    list.Add((T)Convert.ChangeType(t, typeof(T)));
                }

                for (int i = 0; i < 5; i++)
                {
                    var t = new TestConfig()
                    {
                        Lv = 1, Atk = 10
                    };
                    list.Add((T)Convert.ChangeType(t, typeof(T)));
                }
            }
            else
            {
                for (int i = 0; i < 100000; i++)
                {
                    var kvconfig = new KeyValueTestConfig()
                    {
                        Id    = $"ID_{i + 1}",
                        Value = $"V_{i + 1}"
                    };
                    list.Add((T)Convert.ChangeType(kvconfig, typeof(T)));
                }
            }

            return(list);
        }