public static void Build() { try { MessagePackResolver.SetupMessagePackResolver(); } catch { // ignored } var builder = new DatabaseBuilder(); builder = BuildParson(builder); builder = BuildSkill(builder); builder = BuildSkillParameter(builder); byte[] data = builder.Build(); string resourcesDir = $"{Application.dataPath}/Resources/"; string fileName = MasterDataDb.MASTER_RESOURCE_PATH + ".bytes"; Directory.CreateDirectory(resourcesDir); using (var fs = new FileStream(resourcesDir + fileName, FileMode.Create)) { fs.Write(data, 0, data.Length); } Debug.Log($"Write byte[] to: {resourcesDir + fileName}"); AssetDatabase.Refresh(); }
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)); }
private static void BuildMasterData() { try { CompositeResolver.RegisterAndSetAsDefault(new [] { MasterMemoryResolver.Instance, GeneratedResolver.Instance, StandardResolver.Instance }); } catch { } var builder = new DatabaseBuilder(); builder = BuildParson(builder); builder = BuildSkill(builder); builder = BuildSkillParameter(builder); byte[] data = builder.Build(); var resourcesDir = $"{Application.dataPath}/Resources"; Directory.CreateDirectory(resourcesDir); var filename = "/master-data.bytes"; using (var fs = new FileStream(resourcesDir + filename, FileMode.Create)) { fs.Write(data, 0, data.Length); } Debug.Log($"Write byte[] to: {resourcesDir + filename}"); AssetDatabase.Refresh(); }
public MomentaryDatabaseFixture(DatabaseBuilder builder) { _database = builder.Build(); var contextBuilder = new DbContextOptionsBuilder <TContext>() .UseNpgsql(builder.TransientConnectionString); DatabaseContext = (TContext)Activator.CreateInstance(typeof(TContext), contextBuilder); DatabaseContext.Database.EnsureCreated(); }
public Commands(IServiceProvider serviceProvider, IConfiguration configuration, IDatabaseService databaseService, ILoggerFactory loggerFactory) { var databaseBuilder = new DatabaseBuilder(serviceProvider, configuration, new ObjectFactory(MetaPopulation.Instance, typeof(User)), this.IsolationLevel, this.CommandTimeout); databaseService.Database = databaseBuilder.Build(); loggerFactory.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true }); NLog.LogManager.LoadConfiguration("nlog.config"); }
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)); }
void BuildDatabase(bool fetchIconsOnly) { var libraPath = System.IO.Path.Combine(Config.SupplementalPath, "app_data.sqlite"); var realm = new SaintCoinach.ARealmReversed(Config.GamePath, "SaintCoinach.History.zip", SaintCoinach.Ex.Language.English, libraPath); var libra = new SQLite.SQLiteConnection(libraPath, SQLite.SQLiteOpenFlags.ReadOnly); var builder = new DatabaseBuilder(libra, realm); DatabaseBuilder.PrintLine($"Game version: {realm.GameVersion}"); DatabaseBuilder.PrintLine($"Definition version: {realm.DefinitionVersion}"); var processing = Stopwatch.StartNew(); builder.Build(fetchIconsOnly); if (!fetchIconsOnly) SpecialOutput.Run(); processing.Stop(); DatabaseBuilder.PrintLine($"Processing elapsed: {processing.Elapsed}"); }
void BuildDatabase(bool fetchIconsOnly) { var path = _paths.FirstOrDefault(p => Directory.Exists(p)); var realm = new SaintCoinach.ARealmReversed(path, "SaintCoinach.History.zip", SaintCoinach.Ex.Language.English, "app_data.sqlite"); var libra = new SQLite.SQLiteConnection("app_data.sqlite", SQLite.SQLiteOpenFlags.ReadOnly); var builder = new DatabaseBuilder(libra, realm); DatabaseBuilder.PrintLine($"Game version: {realm.GameVersion}"); DatabaseBuilder.PrintLine($"Definition version: {realm.DefinitionVersion}"); OneTimeExports.Run(realm); var processing = Stopwatch.StartNew(); builder.Build(fetchIconsOnly); if (!fetchIconsOnly) { SpecialOutput.Run(); } processing.Stop(); DatabaseBuilder.PrintLine($"Processing elapsed: {processing.Elapsed}"); }
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}"); } }