private static void FileAndSaveTest() { var source = new DotNetConfigSource(DotNetConfigSource.GetFullConfigPath()); var config = source.Configs["appSettings"]; config = source.Configs["Pets"]; AssertEquals("rover", config.Get("dog")); AssertEquals("muffy", config.Get("cat")); Assert(config.Get("not here") == null, "Should not be present"); config.Set("dog", "Spots"); config.Set("cat", "Misha"); AssertEquals("Spots", config.Get("dog")); AssertEquals("Misha", config.Get("cat")); // Cannot perform save yet until technical issues resolved /* * string fileName = "DotNetConfigSourceTests.exe.config"; * source.Save (); * * source = new DotNetConfigSource (); * config = source.Configs["Pets"]; * AssertEquals ("Spots", config.Get ("dog")); * AssertEquals ("Misha", config.Get ("cat")); * * File.Delete (fileName); */ }
public WinterNationals2011PairsScorer() { InitializeComponent(); m_configParameters = new DotNetConfigSource(DotNetConfigSource.GetFullConfigPath()); getFieldName("GoogleSiteName"); Globals.m_rootDirectory = Directory.GetCurrentDirectory(); loadEventPageMapping(); }
static AppConfig() { var userConfigFile = Path.Combine(ApplicationData, "user.config"); if (!File.Exists(userConfigFile)) { File.Copy(DotNetConfigSource.GetFullConfigPath(), userConfigFile); } configSource = new DotNetConfigSource(userConfigFile); appSettings = configSource.Configs ["appSettings"]; }
private static void FileTest() { var source = new DotNetConfigSource(DotNetConfigSource.GetFullConfigPath()); var config = source.Configs["appSettings"]; Assert(config != null, "IConfig is null"); AssertEquals("My App", config.Get("App Name")); config = source.Configs["Pets"]; AssertEquals("rover", config.Get("dog")); AssertEquals("muffy", config.Get("cat")); Assert(config.Get("not here") == null, "Should not be present"); }
static Config() { AppConfigRoot = new Nini.Config.DotNetConfigSource(DotNetConfigSource.GetFullConfigPath()); AppSettings = AppConfigRoot.Configs["appSettings"]; bool hasExtraConfig = false; IConfigSource extraConfigRoot = null; if (File.Exists(ExtraConfigFile)) { hasExtraConfig = true; ExtraConfigRoot = new Nini.Config.XmlConfigSource(ExtraConfigFile); extraConfigRoot = ExtraConfigRoot; } if (File.Exists(PrivateExtraConfigFile)) { hasExtraConfig = true; PrivateExtraConfigRoot = new Nini.Config.XmlConfigSource(PrivateExtraConfigFile); if (extraConfigRoot != null) { extraConfigRoot.Merge(PrivateExtraConfigRoot); } else { extraConfigRoot = PrivateExtraConfigRoot; } } if (hasExtraConfig) { ExtraConfig = extraConfigRoot.Configs["Settings"]; RconServerAddress = ExtraConfig.GetString("RconServerAddress"); RconServerPort = ExtraConfig.GetInt("RconServerPort"); RconServerPassword = ExtraConfig.GetString("RconServerPassword"); } else { throw new ApplicationException("Can't find config file: " + ExtraConfigFile); } }