From e515cdddec435e97e9ed4722de08ee410e94a7e6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 21 Feb 2013 17:26:19 -0800 Subject: Simplification of HG configs: HomeURI and GatekeeperURI now are defined as default under [Startup]. They can then be overwritten in the other sections (but probably shouldn't). I kept the existing code for backwards compatibility, so this should not cause any breaks from people's current configurations. But people should move to have these 2 vars under [Startup] -- see OpenSim.ini.example and Robust.HG.ini.example. And yes, both names now end with "URI" for consistency. --- OpenSim/Framework/Util.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index d9148fb..1700d3e 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -863,7 +863,7 @@ namespace OpenSim.Framework return FileName; } - // Nini (config) related Methods + #region Nini (config) related Methods public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName) { if (!File.Exists(fileName)) @@ -886,6 +886,26 @@ namespace OpenSim.Framework } } + public static string GetConfigVarWithDefaultSection(IConfigSource config, string varname, string section) + { + // First, check the Startup section, the default section + IConfig cnf = config.Configs["Startup"]; + if (cnf == null) + return string.Empty; + string val = cnf.GetString(varname, string.Empty); + + // Then check for an overwrite of the default in the given section + if (!string.IsNullOrEmpty(section)) + { + cnf = config.Configs[section]; + if (cnf != null) + val = cnf.GetString(varname, val); + } + + return val; + } + #endregion + public static float Clip(float x, float min, float max) { return Math.Min(Math.Max(x, min), max); -- cgit v1.1