MongoDB.Driver.MongoUrlBuilder.ParseTimeSpan C# (CSharp) Méthode

ParseTimeSpan() static private méthode

static private ParseTimeSpan ( string name, string s ) : System.TimeSpan
name string
s string
Résultat System.TimeSpan
        internal static TimeSpan ParseTimeSpan(string name, string s)
        {
            TimeSpan result;
            if (TryParseTimeSpan(name, s, out result))
            {
                return result;
            }
            else
            {
                throw new FormatException(FormatMessage(name, s));
            }
        }

Usage Example

 private TimeSpan ToTimeSpan(string keyword, object value)
 {
     if (value is TimeSpan)
     {
         return((TimeSpan)value);
     }
     else if (value is string)
     {
         return(MongoUrlBuilder.ParseTimeSpan(keyword, (string)value));
     }
     else
     {
         return(TimeSpan.FromSeconds(Convert.ToDouble(value)));
     }
 }