aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorMelanie2013-02-23 20:37:09 +0000
committerMelanie2013-02-23 20:37:09 +0000
commite3ea2c4beefb65ba997beab1509aa996a46f7864 (patch)
tree778cba450e788b13f4d000c6e49f3d94bd25f65c /OpenSim/Framework/Util.cs
parentMerge branch 'master' into careminster (diff)
parentMore clarification on the [Groups] section (diff)
downloadopensim-SC-e3ea2c4beefb65ba997beab1509aa996a46f7864.zip
opensim-SC-e3ea2c4beefb65ba997beab1509aa996a46f7864.tar.gz
opensim-SC-e3ea2c4beefb65ba997beab1509aa996a46f7864.tar.bz2
opensim-SC-e3ea2c4beefb65ba997beab1509aa996a46f7864.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 724e38b..aadcdc8 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -916,6 +916,44 @@ namespace OpenSim.Framework
916 916
917 return val; 917 return val;
918 } 918 }
919
920 /// <summary>
921 /// Gets the value of a configuration variable by looking into
922 /// multiple sections in order. The latter sections overwrite
923 /// any values previously found.
924 /// </summary>
925 /// <typeparam name="T">Type of the variable</typeparam>
926 /// <param name="config">The configuration object</param>
927 /// <param name="varname">The configuration variable</param>
928 /// <param name="sections">Ordered sequence of sections to look at</param>
929 /// <returns></returns>
930 public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections)
931 {
932 object val = default(T);
933 foreach (string section in sections)
934 {
935 IConfig cnf = config.Configs[section];
936 if (cnf == null)
937 continue;
938
939 if (typeof(T) == typeof(String))
940 {
941 if (val == null) // no null strings, please
942 val = string.Empty;
943 val = cnf.GetString(varname, (string)val);
944 }
945 else if (typeof(T) == typeof(Boolean))
946 val = cnf.GetBoolean(varname, (bool)val);
947 else if (typeof(T) == typeof(Int32))
948 val = cnf.GetInt(varname, (int)val);
949 else if (typeof(T) == typeof(float))
950 val = cnf.GetFloat(varname, (int)val);
951 else
952 m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T));
953 }
954 return (T)val;
955 }
956
919 #endregion 957 #endregion
920 958
921 public static float Clip(float x, float min, float max) 959 public static float Clip(float x, float min, float max)