11using System ;
22using System . Collections . Generic ;
3- using NETworkManager . Enum ;
43
54namespace NETworkManager . Utilities
65{
6+ /// <summary>
7+ /// Class provides methods to manage auto refresh time.
8+ /// </summary>
79 public static class AutoRefreshTime
810 {
9- public static List < AutoRefreshTimeInfo > Defaults => new List < AutoRefreshTimeInfo >
11+ /// <summary>
12+ /// Method returns a list with default <see cref="AutoRefreshTimeInfo"/>s.
13+ /// </summary>
14+ public static IEnumerable < AutoRefreshTimeInfo > GetDefaults => new List < AutoRefreshTimeInfo >
1015 {
1116 new AutoRefreshTimeInfo ( 5 , TimeUnit . Second ) ,
1217 new AutoRefreshTimeInfo ( 15 , TimeUnit . Second ) ,
@@ -15,20 +20,54 @@ public static class AutoRefreshTime
1520 new AutoRefreshTimeInfo ( 5 , TimeUnit . Minute ) ,
1621 } ;
1722
23+ /// <summary>
24+ /// Method to calculate a <see cref="TimeSpan"/> based on <see cref="AutoRefreshTimeInfo"/>.
25+ /// </summary>
26+ /// <param name="info"><see cref="AutoRefreshTimeInfo"/> to calculate <see cref="TimeSpan"/></param>
27+ /// <returns>Returns the calculated <see cref="TimeSpan"/>.</returns>
1828 public static TimeSpan CalculateTimeSpan ( AutoRefreshTimeInfo info )
1929 {
2030 switch ( info . TimeUnit )
2131 {
22- // Seconds
32+ // Calculate the seconds
2333 case TimeUnit . Second :
2434 return new TimeSpan ( 0 , 0 , info . Value ) ;
25- // Minutes
35+ // Calculate the minutes
2636 case TimeUnit . Minute :
2737 return new TimeSpan ( 0 , info . Value * 60 , 0 ) ;
28- // Hours
29- default :
38+ // Calculate the hours
39+ case TimeUnit . Hour :
3040 return new TimeSpan ( info . Value * 60 , 0 , 0 ) ;
41+ case TimeUnit . None :
42+ default :
43+ throw new Exception ( "Wrong time unit." ) ;
3144 }
3245 }
46+
47+ /// <summary>
48+ /// Enum for time units.
49+ /// </summary>
50+ public enum TimeUnit
51+ {
52+ /// <summary>
53+ /// No time unit.
54+ /// </summary>
55+ None ,
56+
57+ /// <summary>
58+ /// Second(s) time unit.
59+ /// </summary>
60+ Second ,
61+
62+ /// <summary>
63+ /// Minute(s) time unit.
64+ /// </summary>
65+ Minute ,
66+
67+ /// <summary>
68+ /// Hour(s) time unit.
69+ /// </summary>
70+ Hour
71+ }
3372 }
3473}
0 commit comments