Exemplo n.º 1
0
        private static MemoryDatabase BuildLargeCacheSet()
        {
            var builder = new DatabaseBuilder();

            // the file contains 1 million password blacklist entries
            var passwordEntries   = File.ReadAllLines("Cache\\Mocks\\passwordblacklist.txt");
            var passwordBlacklist = passwordEntries.Select(entry => new PasswordBlacklist {
                Value = entry
            }).ToList();

            var random = new Random();

            // build a search list by picking one million random values
            _searchList = new List <PasswordBlacklist>();

            for (var i = 0; i <= SearchListCount; i++)
            {
                var index = random.Next(1, SearchListCount - 10);
                var entry = passwordBlacklist[index];

                _searchList.Add(entry);
            }

            builder.Append(passwordBlacklist);

            var data = builder.Build();

            return(new MemoryDatabase(data));
        }
Exemplo n.º 2
0
 private static DatabaseBuilder BuildSkill(DatabaseBuilder builder)
 {
     builder.Append(new[]
     {
         new Skill {SkillID = 0, SkillName = "スキル0"},
         new Skill {SkillID = 1, SkillName = "スキル1"},
         new Skill {SkillID = 2, SkillName = "スキル2"},
         new Skill {SkillID = 3, SkillName = "スキル3"},
     });
     return builder;
 }
Exemplo n.º 3
0
        private static MemoryDatabase BuildSmallCacheSet()
        {
            var builder = new DatabaseBuilder();

            var rawPlayerData = File.ReadAllText("Cache\\Mocks\\players.json");

            var players = JsonSerializer.Deserialize <Player[]>(rawPlayerData);

            builder.Append(players);

            var data = builder.Build();

            return(new MemoryDatabase(data));
        }
Exemplo n.º 4
0
 private static DatabaseBuilder BuildParson(DatabaseBuilder builder)
 {
     builder.Append(new[]
     {
         new Person {PersonId = 0, Age = 13, Gender = Gender.Male, Name = "Dana Terry"},
         new Person {PersonId = 1, Age = 17, Gender = Gender.Male, Name = "Kirk Obrien"},
         new Person {PersonId = 2, Age = 31, Gender = Gender.Male, Name = "Wm Banks"},
         new Person {PersonId = 3, Age = 44, Gender = Gender.Male, Name = "Karl Benson"},
         new Person {PersonId = 4, Age = 23, Gender = Gender.Male, Name = "Jared Holland"},
         new Person {PersonId = 5, Age = 27, Gender = Gender.Female, Name = "Jeanne Phelps"},
         new Person {PersonId = 6, Age = 25, Gender = Gender.Female, Name = "Willie Rose"},
         new Person {PersonId = 7, Age = 11, Gender = Gender.Female, Name = "Shari Gutierrez"},
         new Person {PersonId = 8, Age = 63, Gender = Gender.Female, Name = "Lori Wilson"},
         new Person {PersonId = 9, Age = 34, Gender = Gender.Female, Name = "Lena Ramsey"},
     });
     return builder;
 }
    private static DatabaseBuilder BuildSkillParameter(DatabaseBuilder builder)
    {
        var skillParameters = new List <SkillParameter> ();

        for (int i = 0; i < 4; i++)
        {
            for (int lv = 1; lv < 10; lv++)
            {
                skillParameters.Add(new SkillParameter {
                    SkillID = i,
                    SkillLv = lv,
                    Damage  = lv * 100
                });
            }
        }
        builder.Append(skillParameters);
        return(builder);
    }
Exemplo n.º 6
0
        private static void Test1()
        {
            // to create database, use DatabaseBuilder and Append method.
            var builder = new DatabaseBuilder();

            builder.Append(new Person[]
            {
                new Person {
                    PersonId = 0, Age = 13, Gender = Gender.Male, Name = "Dana Terry"
                },
                new Person {
                    PersonId = 1, Age = 17, Gender = Gender.Male, Name = "Kirk Obrien"
                },
                new Person {
                    PersonId = 2, Age = 31, Gender = Gender.Male, Name = "Wm Banks"
                },
                new Person {
                    PersonId = 3, Age = 44, Gender = Gender.Male, Name = "Karl Benson"
                },
                new Person {
                    PersonId = 4, Age = 23, Gender = Gender.Male, Name = "Jared Holland"
                },
                new Person {
                    PersonId = 5, Age = 27, Gender = Gender.Female, Name = "Jeanne Phelps"
                },
                new Person {
                    PersonId = 6, Age = 25, Gender = Gender.Female, Name = "Willie Rose"
                },
                new Person {
                    PersonId = 7, Age = 11, Gender = Gender.Female, Name = "Shari Gutierrez"
                },
                new Person {
                    PersonId = 8, Age = 63, Gender = Gender.Female, Name = "Lori Wilson"
                },
                new Person {
                    PersonId = 9, Age = 34, Gender = Gender.Female, Name = "Lena Ramsey"
                },
            });

            // build database binary(you can also use `WriteToStream` for save to file).
            byte[] data = builder.Build();

            // -----------------------

            // for query phase, create MemoryDatabase.
            // (MemoryDatabase is recommended to store in singleton container(static field/DI)).
            var db = new MemoryDatabase(data);

            // .PersonTable.FindByPersonId is fully typed by code-generation.
            Person person = db.PersonTable.FindByPersonId(1);

            // Multiple key is also typed(***And * **), Return value is multiple if key is marked with `NonUnique`.
            RangeView <Person> result = db.PersonTable.FindByGenderAndAge((Gender.Female, 23));

            Debug.Log("result");
            foreach (var p in result)
            {
                Debug.Log($"{p.Name}");
            }

            // Get nearest value(choose lower(default) or higher).
            RangeView <Person> age1 = db.PersonTable.FindClosestByAge(31);

            Debug.Log("age1");
            foreach (var p in age1)
            {
                Debug.Log($"{p.Name}");
            }

            // Get range(min-max inclusive).
            RangeView <Person> age2 = db.PersonTable.FindRangeByAge(20, 29);

            Debug.Log("age2");
            foreach (var p in age2)
            {
                Debug.Log($"{p.Name}");
            }
        }