示例#1
0
        private void LoadData()
        {
            var testCount = 100;
            var cardTable = new TemplateTable <string, CardDescription>();

            for (int i = 0; i < 2; i++)
            {
                var delayedLoad = i == 1;
                var tag         = delayedLoad ? "(Delayed)" : "";
                RunTest($"Load{tag} Json", testCount,
                        () =>
                {
                    cardTable.Load(new TemplateTableJsonLoader <string, CardDescription>(
                                       _json, delayedLoad));
                });

                RunTest($"Load{tag} BsonPack", testCount,
                        () =>
                {
                    cardTable.Load(new TemplateTableBsonPackLoader <string, CardDescription>(
                                       new MemoryStream(_bsonPack), delayedLoad));
                });

                RunTest($"Load{tag} ProtobufPack", testCount,
                        () =>
                {
                    cardTable.Load(new TemplateTableProtobufPackLoader <string, CardDescription>(
                                       new MemoryStream(_protobufPack), delayedLoad));
                });
            }
        }
示例#2
0
        private void LoadData()
        {
            var testCount = 100;
            var cardTable = new TemplateTable<string, CardDescription>();

            for (int i = 0; i < 2; i++)
            {
                var delayedLoad = i == 1;
                var tag = delayedLoad ? "(Delayed)" : "";
                RunTest($"Load{tag} Json", testCount,
                        () =>
                        {
                            cardTable.Load(new TemplateTableJsonLoader<string, CardDescription>(
                                               _json, delayedLoad));
                        });

                RunTest($"Load{tag} BsonPack", testCount,
                        () =>
                        {
                            cardTable.Load(new TemplateTableBsonPackLoader<string, CardDescription>(
                                               new MemoryStream(_bsonPack), delayedLoad));
                        });

                RunTest($"Load{tag} ProtobufPack", testCount,
                        () =>
                        {
                            cardTable.Load(new TemplateTableProtobufPackLoader<string, CardDescription>(
                                               new MemoryStream(_protobufPack), delayedLoad));
                        });
            }
        }
示例#3
0
        public TemplateTable <int, TestObject> PrepareTable()
        {
            var table = new TemplateTable <int, TestObject>();

            table.Load(new TestObjectLoader());
            return(table);
        }
 public TemplateTable<int, TestObject> PrepareTable()
 {
     var table = new TemplateTable<int, TestObject>();
     var jsonLoader = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.LoadJson, false);
     table.Load(jsonLoader);
     return table;
 }
示例#5
0
        private void PrepareData()
        {
            var json = File.ReadAllText(@"..\..\CardTable.json");

            _json = json;

            var cardTable = new TemplateTable <string, CardDescription>();

            cardTable.Load(new TemplateTableJsonLoader <string, CardDescription>(json, true));

            // Save BsonPack

            using (var file = File.Create("CardTableBsonPack.bin"))
            {
                new TemplateTableBsonPackSaver <string, CardDescription>().SaveTo(cardTable, file);
            }
            _bsonPack = File.ReadAllBytes("CardTableBsonPack.bin");

            // Save ProtobufPack

            using (var file = File.Create("CardTableProtobufPack.bin"))
            {
                new TemplateTableProtobufPackSaver <string, CardDescription>().SaveTo(cardTable, file);
            }
            _protobufPack = File.ReadAllBytes("CardTableProtobufPack.bin");
        }
示例#6
0
        private void Load()
        {
            var json = File.ReadAllText(@"..\..\CardTable.json");

            _cardTable = new TemplateTable <string, CardDescription>();
            _cardTable.Load(new TemplateTableJsonLoader <string, CardDescription>(json, true));
        }
 public void Test_JsonLoadNow()
 {
     var table = new TemplateTable<int, TestObject>();
     var jsonLoader = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.LoadJson, false);
     table.Load(jsonLoader);
     var value = table[1];
     Assert.Equal("One", value.Name);
 }
        public TemplateTable <int, TestObject> PrepareTable()
        {
            var table      = new TemplateTable <int, TestObject>();
            var jsonLoader = new TemplateTableJsonLoader <int, TestObject>(TestObjectJson.LoadJson, false);

            table.Load(jsonLoader);
            return(table);
        }
 public void Test_JsonPatchNow()
 {
     var table = new TemplateTable<int, TestObject>();
     var jsonLoader = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.LoadJson, false);
     table.Load(jsonLoader);
     var jsonPatcher = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.PatchJson, false);
     table.Update(jsonPatcher);
     var value = table[2];
     Assert.Equal("TwoTwo", value.Name);
 }
 public void Test_JsonUpdateLazy()
 {
     var table = new TemplateTable<int, TestObject>();
     var jsonLoader = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.LoadJson, true);
     table.Load(jsonLoader);
     var jsonUpdater = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.UpdateJson, true);
     table.Update(jsonUpdater);
     var value = table[2];
     Assert.Equal("TwoTwo", value.Name);
 }
示例#11
0
        public void Test_JsonLoadLazy()
        {
            var table      = new TemplateTable <int, TestObject>();
            var jsonLoader = new TemplateTableJsonLoader <int, TestObject>(TestObjectJson.LoadJson, true);

            table.Load(jsonLoader);
            var value = table[1];

            Assert.Equal("One", value.Name);
        }
 public void Test_JsonPatchLoad()
 {
     var table = new TemplateTable<int, TestObject>();
     var jsonLoader = new TemplateTableJsonLoader<int, TestObject>(TestObjectJson.LoadJson, false);
     table.Load(jsonLoader);
     var jsonPatcher = new TemplateTableJsonPatchLoader<int, TestObject>(table, TestObjectJson.PatchJson, false);
     table.Update(jsonPatcher);
     Assert.Equal("One", table[1].Name);
     Assert.Equal(20, table[1].Power);
     Assert.Equal("Three", table[3].Name);
 }
示例#13
0
        public void Test_JsonPatchLoad()
        {
            var table      = new TemplateTable <int, TestObject>();
            var jsonLoader = new TemplateTableJsonLoader <int, TestObject>(TestObjectJson.LoadJson, false);

            table.Load(jsonLoader);
            var jsonPatcher = new TemplateTableJsonPatchLoader <int, TestObject>(table, TestObjectJson.PatchJson, false);

            table.Update(jsonPatcher);
            Assert.Equal("One", table[1].Name);
            Assert.Equal(20, table[1].Power);
            Assert.Equal("Three", table[3].Name);
        }
示例#14
0
        public void Test_JsonUpdateNow()
        {
            var table      = new TemplateTable <int, TestObject>();
            var jsonLoader = new TemplateTableJsonLoader <int, TestObject>(TestObjectJson.LoadJson, false);

            table.Load(jsonLoader);
            var jsonUpdater = new TemplateTableJsonLoader <int, TestObject>(TestObjectJson.UpdateJson, false);

            table.Update(jsonUpdater);
            var value = table[2];

            Assert.Equal("TwoTwo", value.Name);
        }
        public void Test_Load()
        {
            var table = PrepareTable();

            var saver = new TemplateTableProtobufPackSaver<int, TestObject>();
            var stream = new MemoryStream();
            saver.SaveTo(table, stream);
            stream.Seek(0, SeekOrigin.Begin);

            var loader = new TemplateTableProtobufPackLoader<int, TestObject>(stream, false);
            var table2 = new TemplateTable<int, TestObject>();
            table2.Load(loader);

            Assert.Equal(table.Count, table2.Count);
            Assert.Equal(table[1].Name, table2[1].Name);
        }
示例#16
0
        public void Test_Load()
        {
            var table = PrepareTable();

            var saver  = new TemplateTableProtobufPackSaver <int, TestObject>();
            var stream = new MemoryStream();

            saver.SaveTo(table, stream);
            stream.Seek(0, SeekOrigin.Begin);

            var loader = new TemplateTableProtobufPackLoader <int, TestObject>(stream, false);
            var table2 = new TemplateTable <int, TestObject>();

            table2.Load(loader);

            Assert.Equal(table.Count, table2.Count);
            Assert.Equal(table[1].Name, table2[1].Name);
        }
示例#17
0
        private void PrepareData()
        {
            var json = File.ReadAllText(@"..\..\CardTable.json");
            _json = json;

            var cardTable = new TemplateTable<string, CardDescription>();
            cardTable.Load(new TemplateTableJsonLoader<string, CardDescription>(json, true));

            // Save BsonPack

            using (var file = File.Create("CardTableBsonPack.bin"))
            {
                new TemplateTableBsonPackSaver<string, CardDescription>().SaveTo(cardTable, file);
            }
            _bsonPack = File.ReadAllBytes("CardTableBsonPack.bin");

            // Save ProtobufPack

            using (var file = File.Create("CardTableProtobufPack.bin"))
            {
                new TemplateTableProtobufPackSaver<string, CardDescription>().SaveTo(cardTable, file);
            }
            _protobufPack = File.ReadAllBytes("CardTableProtobufPack.bin");
        }
 public TemplateTable<int, TestObject> PrepareTable()
 {
     var table = new TemplateTable<int, TestObject>();
     table.Load(new TestObjectLoader());
     return table;
 }
示例#19
0
 private void Load()
 {
     var json = File.ReadAllText(@"..\..\CardTable.json");
     _cardTable = new TemplateTable<string, CardDescription>();
     _cardTable.Load(new TemplateTableJsonLoader<string, CardDescription>(json, true));
 }