private static CombinedSettings LoadSettings(string settingsJsonPath) { CombinedSettings settings = new CombinedSettings(); string settingsJson = File.ReadAllText(settingsJsonPath); return(JsonConvert.DeserializeObject <CombinedSettings>(settingsJson, serializerSettings)); }
private static void SetSettings(Table table, CombinedSettings settings) { // Set and write security SecureDatabase db = new SecureDatabase(); db.SetSecurity(table.Name, settings.Security); db.SaveSecurity(table.Name); // Create/Modify columns foreach (ColumnDetails cd in settings.Schema) { table.AddColumn(cd); } }
private static void SetSettings(string tableName, string settingsJsonPath) { Console.WriteLine("Applying settings from '{0}' to '{1}'...", settingsJsonPath, tableName); // Read settings file CombinedSettings settings = LoadSettings(settingsJsonPath); // Create table, if required SecureDatabase db = new SecureDatabase(); if (!db.TableExists(tableName)) { db.AddTable(tableName, settings.ItemCountLimit); } // Apply the settings SetSettings(db[tableName], settings); }
private static void GetSettings(string tableName, string settingsJsonPath) { Console.WriteLine("Reading settings from '{0}' and writing to '{1}'...", tableName, settingsJsonPath); CombinedSettings settings = new CombinedSettings(); SecureDatabase db = new SecureDatabase(); settings.Security = db.Security(tableName); Table t = db[tableName]; settings.ItemCountLimit = t.PartitionCount * ushort.MaxValue; settings.Schema = new List <ColumnDetails>(t.ColumnDetails); string settingsJson = JsonConvert.SerializeObject(settings, serializerSettings); File.WriteAllText(settingsJsonPath, settingsJson); }