TryGetAndRemove() static private method

static private TryGetAndRemove ( string>.Dictionary dict, string name, string &value, bool required ) : bool
dict string>.Dictionary
name string
value string
required bool
return bool
Beispiel #1
0
        internal static bool TryGetAndRemove(Dictionary <string, string> dict, string name, out TimeSpan value, bool required)
        {
            if (ConfigurationHelper.TryGetAndRemove(dict, name, out string tmp, required) && TimeSpan.TryParse(tmp, out value))
            {
                return(true);
            }

            if (required)
            {
                throw new Exception("Missing or invalid parameter: " + (String.IsNullOrEmpty(name) ? "element content" : name));
            }

            value = TimeSpan.Zero;
            return(false);
        }