コード例 #1
0
        public static TimeSpan CalculateTimeSpan(AutoRefreshTimeInfo info)
        {
            switch (info.TimeUnit)
            {
            // Seconds
            case TimeUnit.Second:
                return(new TimeSpan(0, 0, info.Value));

            // Minutes
            case TimeUnit.Minute:
                return(new TimeSpan(0, info.Value * 60, 0));

            // Hours
            default:
                return(new TimeSpan(info.Value * 60, 0, 0));
            }
        }
コード例 #2
0
        public static TimeSpan CalculateTimeSpan(AutoRefreshTimeInfo info)
        {
            // Seconds
            if (info.TimeUnit == TimeUnit.Second)
            {
                return(new TimeSpan(0, 0, info.Value));
            }

            // Minutes
            else if (info.TimeUnit == TimeUnit.Minute)
            {
                return(new TimeSpan(0, info.Value * 60, 0));
            }

            // Hours
            else
            {
                return(new TimeSpan(info.Value * 60, 0, 0));
            }
        }
コード例 #3
0
        /// <summary>
        /// Method to calculate a <see cref="TimeSpan"/> based on <see cref="AutoRefreshTimeInfo"/>.
        /// </summary>
        /// <param name="info"><see cref="AutoRefreshTimeInfo"/> to calculate <see cref="TimeSpan"/></param>
        /// <returns>Returns the calculated <see cref="TimeSpan"/>.</returns>
        public static TimeSpan CalculateTimeSpan(AutoRefreshTimeInfo info)
        {
            switch (info.TimeUnit)
            {
            // Calculate the seconds
            case TimeUnit.Second:
                return(new TimeSpan(0, 0, info.Value));

            // Calculate the minutes
            case TimeUnit.Minute:
                return(new TimeSpan(0, info.Value * 60, 0));

            // Calculate the hours
            case TimeUnit.Hour:
                return(new TimeSpan(info.Value * 60, 0, 0));

            case TimeUnit.None:
            default:
                throw new Exception("Wrong time unit.");
            }
        }