public void TestCanConvertValidValues(string val, EDayOfWeek expected) { var result1 = val.ParseUsingExpressions().AsEnumerable().First(); Assert.AreEqual(expected, result1); //Don't do this in real life kids... var result2 = val.ParseUsingDelegates().AsEnumerable().First(); Assert.AreEqual(expected, result2); }
private int[] SpecifyTime(string val) { EDayOfWeek dow = EDayOfWeek.Nothing; switch (val[0]) { case '月': dow = EDayOfWeek.Monday; break; case '火': dow = EDayOfWeek.Tuesday; break; case '水': dow = EDayOfWeek.Wednesday; break; case '木': dow = EDayOfWeek.Thursday; break; case '金': dow = EDayOfWeek.Friday; break; case '土': dow = EDayOfWeek.Saturday; break; case '日': dow = EDayOfWeek.Sunday; break; default: break; } if (dow == EDayOfWeek.Nothing) { return(null); } return(new int[2] { (int)dow, int.Parse(val[1].ToString()) }); }
private bool IsValid(EDayOfWeek periodday, DayOfWeek dayofweek) { switch (periodday) { case EDayOfWeek.EveryDay: return(true); case EDayOfWeek.WeekEnd: if (dayofweek == System.DayOfWeek.Saturday) { return(true); } if (dayofweek == System.DayOfWeek.Sunday) { return(true); } return(false); case EDayOfWeek.WorkingDay: if (dayofweek == System.DayOfWeek.Saturday) { return(false); } if (dayofweek == System.DayOfWeek.Sunday) { return(false); } return(true); case EDayOfWeek.Monday: if (dayofweek == System.DayOfWeek.Monday) { return(true); } return(false); case EDayOfWeek.Tuesday: if (dayofweek == System.DayOfWeek.Tuesday) { return(true); } return(false); case EDayOfWeek.Wednesday: if (dayofweek == System.DayOfWeek.Wednesday) { return(true); } return(false); case EDayOfWeek.Thursday: if (dayofweek == System.DayOfWeek.Thursday) { return(true); } return(false); case EDayOfWeek.Friday: if (dayofweek == System.DayOfWeek.Friday) { return(true); } return(false); case EDayOfWeek.Saturday: if (dayofweek == System.DayOfWeek.Saturday) { return(true); } return(false); case EDayOfWeek.Sunday: if (dayofweek == System.DayOfWeek.Sunday) { return(true); } return(false); } return(false); }