示例#1
0
        /// <summary>
        /// Returns a node as a <see cref="TimeSpan"/>.
        /// </summary>
        /// <param name="path">A Json+ query path that identifies a node in the current context.</param>
        /// <param name="defaultValue">The default value to return if the node specified by <paramref name="path"/> does not exist. Defaults to `null`.</param>
        /// <param name="allowInfinite">Set to `true` to allow the keyword `infinite`. Otherwise, `false`. Defaults to `true`.</param>
        /// <returns>The <see cref="TimeSpan"/> value of the node specified by <paramref name="path"/>, or <paramref name="defaultValue"/> if the node does not exist.</returns>
        public TimeSpan GetTimeSpan(JsonPlusPath path, TimeSpan?defaultValue = null, bool allowInfinite = true)
        {
            JsonPlusValue value = GetNode(path);

            if (value == null)
            {
                return(defaultValue.GetValueOrDefault());
            }

            return(value.GetTimeSpan(allowInfinite));
        }