public static void SetTo(DbConfig config) { config.SetKey(DatabaseName); config.SetKey(DefaultSchema); config.SetKey(DeleteOnClose); config.SetKey(StorageSystem); config.SetKey(CellCacheType); }
static DbConfig() { Empty = new DbConfig(true); SystemDefault = new DbConfig(true); SystemConfigKeys.SetTo(SystemDefault); DatabaseDefault = new DbConfig(true); DatabaseConfigKeys.SetTo(DatabaseDefault); }
public void Extensions_LoadFromProperties() { var properties = new StringBuilder(); properties.AppendLine("system.readOnly = false"); properties.AppendLine("caching.type = Memory"); IDbConfig dbConfig = null; Assert.DoesNotThrow(() => dbConfig = new DbConfig(new StringConfigSource(properties.ToString()))); Assert.IsNotNull(dbConfig); Assert.DoesNotThrow(() => dbConfig.Load(new PropertiesConfigFormatter())); Assert.DoesNotThrow(() => Assert.IsNotNull(dbConfig.GetKey("system.readOnly"))); bool readOnly = true; Assert.DoesNotThrow(() => readOnly = dbConfig.GetBoolean("system.readOnly")); Assert.IsFalse(readOnly); }
public void GetKeysFromChild() { IDbConfig config = null; Assert.DoesNotThrow(() => config = DbConfig.SystemDefault); Assert.IsNotNull(config); Assert.DoesNotThrow(() => config.SetKey(new ConfigKey("test.oneKey", "one", typeof(string)))); IDbConfig child = null; Assert.DoesNotThrow(() => child = new DbConfig(config)); Assert.IsNotNull(child); Assert.IsNotNull(child.Parent); Assert.DoesNotThrow(() => config.SetKey(new ConfigKey("test.oneKey", 45, typeof(int)))); ConfigKey key = null; Assert.DoesNotThrow(() => key = config.GetKey("test.oneKey")); Assert.IsNotNull(key); Assert.AreEqual(typeof(int), key.ValueType); Assert.AreEqual(45, key.DefaultValue); }
private static IDbConfig GetConfig(IDbConfig parentConfig, string path, string configFile) { if (configFile == null) configFile = DefaultConfigFileName; configFile = Path.Combine(path, configFile); bool fileExists = File.Exists(configFile); if (!fileExists) { // if we didn't find the file where it was supposed to be, try to // look for a .conf file into the directory... string[] files = Directory.GetFiles(path, "*.conf"); // if, and only if, we have exactly one .conf file set it as our // config file, otherwise we quit... configFile = files.Length == 1 ? Path.GetFileName(files[0]) : configFile; fileExists = files.Length == 1; } if (!fileExists) return parentConfig; // if the config file exists, we load the settings from there... //TODO: support more formats var config = new DbConfig(parentConfig); config.Load(configFile); return config; }