// Return a value for the parameter. // This is used by most callers to get parameter values. // Note that it outputs a console message if not found. Not found means that the caller // used the wrong string name. public T P<T>(string paramName) { T ret = default(T); if (TryGetParameter(paramName, out ParameterDefnBase pbase)) { ParameterDefn<T> pdef = pbase as ParameterDefn<T>; if (pdef != null) { ret = pdef.Value(); } else { ConvOAR.Globals.log.ErrorFormat("{0} Fetched unknown parameter. Param={1}", _logHeader, paramName); } } return ret; }
// Search through the parameter definitions and return the matching // ParameterDefn structure. // Case does not matter as names are compared after converting to lower case. // Returns 'false' if the parameter is not found. internal static bool TryGetParameter(string paramName, out ParameterDefn defn) { bool ret = false; ParameterDefn foundDefn = new ParameterDefn(); string pName = paramName.ToLower(); foreach (ParameterDefn parm in ParameterDefinitions) { if (pName == parm.name.ToLower()) { foundDefn = parm; ret = true; break; } } defn = foundDefn; return ret; }