Akka.Configuration.Hocon.HoconValue.GetTimeSpan C# (CSharp) Метод

GetTimeSpan() публичный Метод

Retrieves the time span value from this HoconValue.
public GetTimeSpan ( bool allowInfinite = true ) : System.TimeSpan
allowInfinite bool A flag used to set inifinite durations.
Результат System.TimeSpan
        public TimeSpan GetTimeSpan(bool allowInfinite = true)
        {
            string res = GetString();
            if (res.EndsWith("ms"))
            //TODO: Add support for ns, us, and non abbreviated versions (second, seconds and so on) see https://github.com/Lightbendhub/config/blob/master/HOCON.md#duration-format
            {
                var v = res.Substring(0, res.Length - 2);
                return TimeSpan.FromMilliseconds(ParsePositiveValue(v));
            }
            if (res.EndsWith("s"))
            {
                var v = res.Substring(0, res.Length - 1);
                return TimeSpan.FromSeconds(ParsePositiveValue(v));
            }
            if(res.EndsWith("m"))
            {
                var v = res.Substring(0, res.Length - 1);
                return TimeSpan.FromMinutes(ParsePositiveValue(v));
            }
            if(res.EndsWith("h"))
            {
                var v = res.Substring(0, res.Length - 1);
                return TimeSpan.FromHours(ParsePositiveValue(v));
            }
            if (res.EndsWith("d"))
            {
                var v = res.Substring(0, res.Length - 1);
                return TimeSpan.FromDays(ParsePositiveValue(v));
            }
            if(allowInfinite && res.Equals("infinite", StringComparison.OrdinalIgnoreCase))  //Not in Hocon spec
            {
                return Timeout.InfiniteTimeSpan;
            }

            return TimeSpan.FromMilliseconds(ParsePositiveValue(res));
        }