public LogonTime(DayOfWeek dayOfWeek, LogonTimeUnit unit, int startPeriod) { if (unit == LogonTimeUnit.Days && startPeriod > 0)//Just ignore it? { throw new ArgumentOutOfRangeException("startPeriod", Resource.DayMidnight); } if (unit == LogonTimeUnit.Hours && startPeriod > 23) { throw new ArgumentOutOfRangeException("startPeriod", Resource.DayHours); } if (unit == LogonTimeUnit.Minutes && startPeriod > 1440) { throw new ArgumentOutOfRangeException("startPeriod", Resource.DayMinutes); } DayOfWeek = dayOfWeek; switch (unit) { case LogonTimeUnit.Days: LogonPeriod = new TimeSpan(0, 23, 59, 59, 999); //inclusive at both ends StartMinutes = 0; break; case LogonTimeUnit.Hours: LogonPeriod = new TimeSpan(0, 0, 59, 59, 999); //inclusive at both ends StartMinutes = startPeriod * 60; break; case LogonTimeUnit.Minutes: LogonPeriod = new TimeSpan(0, 0, 0, 59, 999); //inclusive at both ends StartMinutes = startPeriod; break; } }
public void Add(DayOfWeek dayOfWeek, LogonTimeUnit unit, int startPeriod) { Times.Add(new LogonTime(dayOfWeek, unit, startPeriod)); }
public void Add(DayOfWeek dayOfWeek, LogonTimeUnit unit, uint startPeriod) { Times.Add(new LogonTime(dayOfWeek, unit, startPeriod)); }
public LogonTime(DayOfWeek dayOfWeek, LogonTimeUnit unit, uint startPeriod) { if (unit == LogonTimeUnit.Days && startPeriod > 0)//Just ignore it? throw new ArgumentOutOfRangeException("startPeriod", "A day starts at midnight."); if (unit == LogonTimeUnit.Hours && startPeriod > 23) throw new ArgumentOutOfRangeException("startPeriod", "A day only has 24 hours."); if (unit == LogonTimeUnit.Minutes && startPeriod > 1440) throw new ArgumentOutOfRangeException("startPeriod", "A day only has 1440 minutes."); DayOfWeek = dayOfWeek; switch (unit) { case LogonTimeUnit.Days: LogonPeriod = new TimeSpan(0, 23, 59, 59, 999);//inclusive at both ends StartMinutes = 0; break; case LogonTimeUnit.Hours: LogonPeriod = new TimeSpan(0, 0, 59, 59, 999);//inclusive at both ends StartMinutes = startPeriod * 60; break; case LogonTimeUnit.Minutes: LogonPeriod = new TimeSpan(0, 0, 0, 59, 999);//inclusive at both ends StartMinutes = startPeriod; break; } }