From d0cb4fc3262df2afe2ef34396c7960f7afee6b89 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 25 Feb 2013 23:04:38 +0000 Subject: Move map related settings from [Startup] to a new [Map] section in OpenSim.ini Existing map settings in [Startup] will continue to work, and if present will override anything in [Map] However, the proper place for such settings would now be [Map] This is to reduce the use of [Startup] as a bag for non-generic settings which should really go in sections, in common with other settings. This commit also extends Diva's previous work to allow a default setting to be given when looking at multiple sections for settings. --- OpenSim/Framework/Util.cs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 8b8e507..0fa54b2 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -917,7 +917,25 @@ namespace OpenSim.Framework /// public static T GetConfigVarFromSections(IConfigSource config, string varname, string[] sections) { - object val = default(T); + return GetConfigVarFromSections(config, varname, sections, default(T)); + } + + /// + /// Gets the value of a configuration variable by looking into + /// multiple sections in order. The latter sections overwrite + /// any values previously found. + /// + /// + /// If no value is found then the given default value is returned + /// + /// Type of the variable + /// The configuration object + /// The configuration variable + /// Ordered sequence of sections to look at + /// Default value + /// + public static T GetConfigVarFromSections(IConfigSource config, string varname, string[] sections, object val) + { foreach (string section in sections) { IConfig cnf = config.Configs[section]; @@ -925,11 +943,7 @@ namespace OpenSim.Framework continue; if (typeof(T) == typeof(String)) - { - if (val == null) // no null strings, please - val = string.Empty; val = cnf.GetString(varname, (string)val); - } else if (typeof(T) == typeof(Boolean)) val = cnf.GetBoolean(varname, (bool)val); else if (typeof(T) == typeof(Int32)) @@ -937,8 +951,9 @@ namespace OpenSim.Framework else if (typeof(T) == typeof(float)) val = cnf.GetFloat(varname, (int)val); else - m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T)); + m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); } + return (T)val; } -- cgit v1.1