/// <param name="primary">the primary string to attempt to convert into a integer</param> /// <param name="opt">the option to use as secondary + default if no primary given</param> /// <returns>a parsed integer</returns> private int GetInteger(string primary, ConfigOption <int> opt) { string value = primary; if (value == null) { value = config.Get(opt.GetCfgOption()); } if (value == null) { return(opt.GetDefault()); } return(System.Convert.ToInt32(value)); }
/// <param name="cfgopt">the configuration option to use for config and default lookup /// </param> /// <param name="primary"> /// the initial string to be used for the value of this configuration /// option (if not provided then config and then the default are used) /// </param> /// <returns>the parsed integer byte range from primary, config, default</returns> private Range <long> GetMinMaxBytes(ConfigOption <long> cfgopt, string primary) { string sval = primary; if (sval == null) { sval = config.Get(cfgopt.GetCfgOption()); } Range <long> range = null; if (sval != null) { string[] pieces = Helper.GetTrimmedStrings(sval); if (pieces.Length == 2) { string min = pieces[0]; string max = pieces[1]; long tMin = StringUtils.TraditionalBinaryPrefix.String2long(min); long tMax = StringUtils.TraditionalBinaryPrefix.String2long(max); if (tMin > tMax) { long tmp = tMin; tMin = tMax; tMax = tmp; } range = new Range <long>(tMin, tMax); } } if (range == null) { long def = cfgopt.GetDefault(); if (def != null) { range = new Range <long>(def, def); } } return(range); }
/// <param name="cfgopt">the configuration option to use for config and default lookup /// </param> /// <param name="primary"> /// the initial string to be used for the value of this configuration /// option (if not provided then config and then the default are used) /// </param> /// <returns>the parsed long range from primary, config, default</returns> private Range <long> GetMinMaxLong(ConfigOption <long> cfgopt, string primary) { string sval = primary; if (sval == null) { sval = config.Get(cfgopt.GetCfgOption()); } Range <long> range = null; if (sval != null) { string[] pieces = Helper.GetTrimmedStrings(sval); if (pieces.Length == 2) { string min = pieces[0]; string max = pieces[1]; long minVal = long.Parse(min); long maxVal = long.Parse(max); if (minVal > maxVal) { long tmp = minVal; minVal = maxVal; maxVal = tmp; } range = new Range <long>(minVal, maxVal); } } if (range == null) { long def = cfgopt.GetDefault(); if (def != null) { range = new Range <long>(def, def); } } return(range); }