/// <summary> /// Converts the days in a <see cref="DaysOfTheWeek"/> value to a sequence of <see cref="DayOfWeek"/> values. /// </summary> /// <param name="source">The days of the week.</param> /// <returns> /// An <see cref="IEnumerable{T}"/> that contains <see cref="DayOfWeek"/> values found in the source /// <see cref="DaysOfTheWeek"/> value. /// </returns> /// <remarks> /// This method is implemented by using deferred execution. The immediate return value is an object that stores all /// the information that is required to perform the action. /// </remarks> public static IEnumerable <DayOfWeek> AsEnumerable(this DaysOfTheWeek source) { if (DaysOfTheWeek.Monday == (source & DaysOfTheWeek.Monday)) { yield return(DayOfWeek.Monday); } if (DaysOfTheWeek.Tuesday == (source & DaysOfTheWeek.Tuesday)) { yield return(DayOfWeek.Tuesday); } if (DaysOfTheWeek.Wednesday == (source & DaysOfTheWeek.Wednesday)) { yield return(DayOfWeek.Wednesday); } if (DaysOfTheWeek.Thursday == (source & DaysOfTheWeek.Thursday)) { yield return(DayOfWeek.Thursday); } if (DaysOfTheWeek.Friday == (source & DaysOfTheWeek.Friday)) { yield return(DayOfWeek.Friday); } if (DaysOfTheWeek.Saturday == (source & DaysOfTheWeek.Saturday)) { yield return(DayOfWeek.Saturday); } if (DaysOfTheWeek.Sunday == (source & DaysOfTheWeek.Sunday)) { yield return(DayOfWeek.Sunday); } }
static void Main(string[] args) { bool validDay = false; while (!validDay) { Console.WriteLine("Please enter the current day of the week: "); string input = Console.ReadLine(); bool isNumeric = int.TryParse(input, out _); if (!isNumeric) { try { DaysOfTheWeek day = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), input); Console.WriteLine("Thanks for letting me know that today is " + day + "!"); validDay = true; } catch (Exception ex) { Console.WriteLine("Please enter an actual day of the week."); } } else { Console.WriteLine("Please enter a string."); } } Console.ReadLine(); }
public static String convertDayToString(DaysOfTheWeek day) { if (day.Equals(DaysOfTheWeek.MONDAY)) { return("Lunes"); } else if (day.Equals(DaysOfTheWeek.TUESDAY)) { return("Martes"); } else if (day.Equals(DaysOfTheWeek.WEDNESDAY)) { return("Miercoles"); } else if (day.Equals(DaysOfTheWeek.THURSDAY)) { return("Jueves"); } else if (day.Equals(DaysOfTheWeek.FRIDAY)) { return("Viernes"); } else if (day.Equals(DaysOfTheWeek.SATURDAY)) { return("Sabado"); } return("Domingo"); }
static void Main(string[] args) { Console.WriteLine("Please enter a day of the week:"); string userInput = Console.ReadLine(); try { DaysOfTheWeek day = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), userInput); if (day == DaysOfTheWeek.Friday) { Console.WriteLine("It's Friday! WOOHOO!"); } else { Console.WriteLine("Ugh, it's not Friday yet?!"); } } catch (Exception ex) { Console.WriteLine("Failed"); Console.WriteLine("Please print actual day of week"); } finally { Console.Read(); } }
public static string WeekRendering(this DaysOfTheWeek days) { switch (days) { case DaysOfTheWeek.monday: return("понедельник"); case DaysOfTheWeek.tuesday: return("вторник"); case DaysOfTheWeek.wednesday: return("среда"); case DaysOfTheWeek.thursday: return("четверг"); case DaysOfTheWeek.friday: return("пятница"); case DaysOfTheWeek.satrday: return("суббота"); case DaysOfTheWeek.sunday: return("воскресенье"); } return(null); }
static void Main(string[] args) { try { Console.WriteLine("Please enter the day of the week."); var day = Console.ReadLine(); DaysOfTheWeek days = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), day); int value; if (int.TryParse(day, out value)) { Console.WriteLine("This is a number. Please enter a day of the week."); } else { for (int i = 0; i < 7; i++) { if (days == (DaysOfTheWeek)i) { Console.WriteLine("You have entered: " + days); } } } } catch (Exception) { Console.WriteLine("Please enter an actual day of the week."); } finally { Console.ReadLine(); } }
private static string TextFromDaysOfTheWeek(DaysOfTheWeek days) { if (days == 0) { return("no days"); } else if (days == DaysOfTheWeek.AllDays) { return("every day"); } else if (days == (DaysOfTheWeek.Saturday | DaysOfTheWeek.Sunday)) { return("weekends"); } else if (days == (DaysOfTheWeek.Monday | DaysOfTheWeek.Tuesday | DaysOfTheWeek.Wednesday | DaysOfTheWeek.Thursday | DaysOfTheWeek.Friday)) { return("weekdays"); } string result = ""; foreach (DaysOfTheWeek day in new[] { DaysOfTheWeek.Monday, DaysOfTheWeek.Tuesday, DaysOfTheWeek.Wednesday, DaysOfTheWeek.Thursday, DaysOfTheWeek.Friday, DaysOfTheWeek.Saturday, DaysOfTheWeek.Sunday }) { if ((days & day) != 0) { if (result != "") { result += ", "; } result += day.ToString().Substring(0, 3); } } return(result); }
/// <summary> /// Creates a WeeklyTrigger that is eligible to fire only during certain weeks. /// </summary> /// <param name="hour">Hour of day trigger will fire.</param> /// <param name="minutes">Minutes of hour (specified in "hour") trigger will fire.</param> /// <param name="daysOfTheWeek">Days of the week task will run.</param> /// <param name="weeksInterval">Number of weeks between task runs.</param> public WeeklyTrigger(short hour, short minutes, DaysOfTheWeek daysOfTheWeek, short weeksInterval) : base() { SetStartTime((ushort)hour, (ushort)minutes); taskTrigger.Type = TaskTriggerType.TIME_TRIGGER_WEEKLY; taskTrigger.Data.weekly.WeeksInterval = (ushort)weeksInterval; taskTrigger.Data.weekly.DaysOfTheWeek = (ushort)daysOfTheWeek; }
static void Main(string[] args) { //1.Create an enum for the days of the week. //2. Prompt the user to enter the current day of the week. try { Console.WriteLine("Please enter the current day of the week:"); string day = Console.ReadLine().ToLower(); //3. Assign the value to a variable of that enum data type you just created. bool isEnum = DaysOfTheWeek.IsDefined(typeof(DaysOfTheWeek), day); if (isEnum == false) { throw new FormatException(); } Console.WriteLine(isEnum); } //4. Wrap the above statement in a try/catch block and have it print "Please enter an actual day of the week." to the console if an error occurs. catch (FormatException ex) { Console.WriteLine("Please enter an actual day of the week."); } Console.ReadLine(); }
static void Main(string[] args) { DaysOfTheWeek ApptDays = DaysOfTheWeek.Monday | DaysOfTheWeek.Wednesday | DaysOfTheWeek.Friday; // loop and HasFlag using list List <string> ldows = Enum.GetNames(typeof(DaysOfTheWeek)).ToList();// convert enum elements to list of string ldows = Enum.GetNames(typeof(DaysOfTheWeek)).ToList(); foreach (string dow in ldows) { DaysOfTheWeek edow; Enum.TryParse(dow, out edow); Console.WriteLine("{0} is {1}included", dow, ApptDays.HasFlag(edow) ? "" : "NOT "); } // loop and HasFlag using Class.Array //Array dows = Enum.GetValues(typeof(DaysOfTheWeek)); // convert enum elements to Class.Array, simpler for HasFlag //foreach (DaysOfTheWeek dow in dows) // Console.WriteLine("{0} is {1}included", dow, ApptDays.HasFlag(dow) ? "" : "NOT "); // alt to HasFlag: if((daysOfTheWeek & DaysOfTheWeek.Monday) == DaysOfTheWeek.Monday) Console.WriteLine(); Console.WriteLine(String.Join(",", ldows)); Console.ReadKey(); }
static void Main(string[] args) { Weeks week = new Weeks(); week.DaysOfTheWeek = new DaysOfTheWeek(); Console.WriteLine("what day of the week is it? "); bool input = false; while (input == false) { try { DaysOfTheWeek today = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), Console.ReadLine(), true); Console.WriteLine("You think today is: {0}", today.ToString()); input = true; } catch (Exception) { Console.WriteLine("Please enter an actual day of the week:"); } } Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Enter the current day of the week:"); for (int t = 1; t < 3; t++) { try { DaysOfTheWeek day = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), Console.ReadLine()); if ((int)day == (int)DateTime.Now.DayOfWeek) { Console.WriteLine("Yes, today is {0}!", day); } else { Console.WriteLine("No, it's not {0}!", day); } break; } catch (ArgumentException) { Console.WriteLine("Please enter an actual day of the week: "); } } Console.ReadLine(); }
private void InitializeDaysOfTheWeek() { DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Monday", ClosedStores = new List <SVWikiLink>() { Shops.MarniesRanch, }, }); DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Tuesday", ClosedStores = new List <SVWikiLink>() { Shops.CarpenterShop, Shops.MarniesRanch, }, }); DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Wednesday", ClosedStores = new List <SVWikiLink>() { Shops.GeneralStore }, QueenOfSauceRerun = true, }); DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Thursday", }); DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Friday", ClosedStoresAfterCommunityCenter = new List <SVWikiLink>() { Shops.CarpenterShop }, EarlyStoreClosures = new List <Tuple <SVWikiLink, string> >() { new Tuple <SVWikiLink, string>(Shops.Blacksmith, "4:00pm") }, TravelingCartOpen = true, }); DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Saturday", ClosedStoresOnSunnyDays = new List <SVWikiLink>() { Shops.FishShop }, }); DaysOfTheWeek.Add(new SVDayOfWeek() { Name = "Sunday", TravelingCartOpen = true, QueenOfSauceNewRecipe = true, }); }
static void Main(string[] args) { foreach (int number in SomeNumbers()) { Console.Write(number.ToString() + " "); } Console.WriteLine(); foreach (int number in EvenSequence(5, 18)) { Console.Write(number.ToString() + " "); } Console.WriteLine(); DaysOfTheWeek days = new DaysOfTheWeek(); foreach (string day in days) { Console.Write(day + " "); } // Output: Sun Mon Tue Wed Thu Fri Sat Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Please enter the current day of the week"); try { String dayString = Console.ReadLine(); DaysOfTheWeek dayValue = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), dayString, true); if (Enum.IsDefined(typeof(DaysOfTheWeek), dayValue) | dayValue.ToString().Contains(",")) { Console.WriteLine("Converted '{0}' to {1}.", dayString, dayValue.ToString()); } else { Console.WriteLine("Please enter an actual day of the week."); } } catch (ArgumentException) { Console.WriteLine("Please enter an actual day of the week."); } finally { Console.ReadLine(); } }
public int GetSpeed(DaysOfTheWeek day, int hour, int overrideSpeed) { if (mDisable) { return(Relativity.sOneMinute); } if (overrideSpeed > 0) { return(overrideSpeed); } int speed = 0; if (mSpeedOverride != 0) { if (mSpeedOverride < 0) { speed = 0; } else { speed = mSpeedOverride; } } else { Dictionary <DaysOfTheWeek, Dictionary <int, int> > days; if ((!Speeds.TryGetValue(GameUtils.GetCurrentWorld(), out days)) && (!Speeds.TryGetValue(WorldName.Undefined, out days))) { speed = Relativity.sOneMinute; } else { Dictionary <int, int> hours; if (!days.TryGetValue(day, out hours)) { speed = Relativity.sOneMinute; } else if (!hours.TryGetValue(hour, out speed)) { speed = Relativity.sOneMinute; } } } int activeSize = Households.NumSims(Household.ActiveHousehold) - mActiveSimFactorMinimum; if (activeSize > 0) { speed -= (int)(speed * activeSize * (mActiveSimFactorReduction / 100f)); if (speed <= 0) { speed = 1; } } return(speed); }
static void Main(string[] args) { bool correctDay = false; do //this loop will check input of user and loop until proper answer is input { try { //user will enter in a day of the week Console.WriteLine("What day is it today?"); string answer = Console.ReadLine(); //this will parse the string to see if it matches any value in the enum DaysOfTheWeek enumAnswer = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), answer); //if it matches, this code will execute and program will end if (Enum.IsDefined(typeof(DaysOfTheWeek), enumAnswer)) { Console.WriteLine("Today is {0}", enumAnswer); correctDay = true; } } catch (Exception ex) { Console.WriteLine("Pleases enter a valid day of the week"); correctDay = false; } finally { Console.WriteLine("Thank you!"); } }while (correctDay == false); Console.ReadLine(); }
static void Main(string[] args) { // User is asked to input day of week Console.WriteLine("Input the current day of the week:"); bool isDay = false;// used as flag for while loop while (isDay == false) { try //try block to see if input matches enum { //input string userDay = Console.ReadLine(); //Parsing user input with enum list which is not case sensitive DaysOfTheWeek day = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), userDay, true); //checking if string or int value entered is in enum if (Enum.IsDefined(typeof(DaysOfTheWeek), day)) { Console.WriteLine($"The day of the week is {day}!"); isDay = true; //satisfies while loop } else { Console.WriteLine("Please enter an actual day of the week"); isDay = false;//repeats while loop } } catch (Exception)//generic exception thrown when input is wrong { Console.WriteLine("Please enter an actual day of the week"); isDay = false; } } Console.ReadLine(); }
static void Main(string[] args) { try { Console.WriteLine("Hi there! Please enter current day:"); string userInput = Console.ReadLine(); DaysOfTheWeek day = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), userInput); for (int i = 0; i < 7; i++) { if (day == (DaysOfTheWeek)i) { Console.WriteLine("Yes! Today is {day}"); } } } catch (Exception ex) { Console.WriteLine("Please enter an actual day of the week." + ex.Message); } finally { Console.ReadLine(); } }
static void Main(string[] args) { //4. Wrap the above statement in a try/catch block and have it print //"Please enter an actual day of the week." to the console if an error occurs. try { //2. Prompt the user to enter the current day of the week. Console.WriteLine("Enter current day:"); string userInput = Console.ReadLine(); //3. Assign the value to a variable of that enum data type you just created. DaysOfTheWeek day = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), userInput.ToLower()); for (int i = 0; i < 7; i++) { if (day == (DaysOfTheWeek)i) { Console.WriteLine($"Yes! Today is {day}"); } } } catch (Exception) { Console.WriteLine("Please enter an actual day of the week."); } finally { Console.ReadLine(); } }
public AlarmTask(float hourOfDay, DaysOfTheWeek days, Sims3.Gameplay.Function func) : this(func){ handle = AlarmManager.Global.AddAlarmDay(hourOfDay, days, OnTimer, "ArthurGibraltarSims3Mod_Daily", AlarmType.NeverPersisted, null); }
private DaysOfTheWeek getDaysOfTheWeek_Monthly() { DaysOfTheWeek dayOfWeek = new DaysOfTheWeek(); if (cbDayInWeekMonthly.Text == "Thứ Hai") { dayOfWeek = DaysOfTheWeek.Monday; } if (cbDayInWeekMonthly.Text == "Thứ Ba") { dayOfWeek = DaysOfTheWeek.Tuesday; } if (cbDayInWeekMonthly.Text == "Thứ Tư") { dayOfWeek = DaysOfTheWeek.Wednesday; } if (cbDayInWeekMonthly.Text == "Thứ Năm") { dayOfWeek = DaysOfTheWeek.Thursday; } if (cbDayInWeekMonthly.Text == "Thứ Sáu") { dayOfWeek = DaysOfTheWeek.Friday; } if (cbDayInWeekMonthly.Text == "Thứ Bảy") { dayOfWeek = DaysOfTheWeek.Saturday; } if (cbDayInWeekMonthly.Text == "Chủ Nhật") { dayOfWeek = DaysOfTheWeek.Sunday; } return(dayOfWeek); }
public MonthlyDOWTrigger(DaysOfTheWeek daysOfWeek = (DaysOfTheWeek)1, MonthsOfTheYear monthsOfYear = (MonthsOfTheYear)0xfff, WhichWeek weeksOfMonth = (WhichWeek)1) : base(TaskTriggerType.MonthlyDOW) { DaysOfWeek = daysOfWeek; MonthsOfYear = monthsOfYear; WeeksOfMonth = weeksOfMonth; }
public Scheduler(bool enabled, DateTime scheduleTime, DaysOfTheWeek daysOfTheWeek, bool startWhenAvailable, bool startOnBatteries) { this.Enabled = enabled; this.ScheduleTime = scheduleTime; this.DaysOfTheWeek = daysOfTheWeek; this.StartWhenAvailable = startWhenAvailable; this.StartOnBatteries = startOnBatteries; }
static void Main(string[] args) { Console.WriteLine("_1-------------------------------------------------------------"); /* * In the following example, the first iteration of the foreach loop causes * execution to proceed in the SomeNumbers iterator method until the first * yield return statement is reached. This iteration returns a value of 3, * and the current location in the iterator method is retained. On the next * iteration of the loop, execution in the iterator method continues from * where it left off, again stopping when it reaches a yield return statement. * This iteration returns a value of 5, and the current location in the iterator * method is again retained. The loop completes when the end of the iterator * method is reached. * The return type of an iterator method or get accessor can be IEnumerable, * IEnumerable<T>, IEnumerator, or IEnumerator<T>. * You can use a yield break statement to end the iteration. * */ foreach (int number in SomeNumbers()) { Console.WriteLine(number.ToString() + " "); } // Output: 3 5 8 Console.WriteLine("_2-------------------------------------------------------------"); /* * The following example uses an iterator method. The iterator method has a * yield return statement that is inside a for loop. In the ListEvenNumbers method, * each iteration of the foreach statement body creates a call to the iterator method, * which proceeds to the next yield return statement. * * The following example has a single yield return statement that is inside a for loop. * In Main, each iteration of the foreach statement body creates a call to the iterator * function, which proceeds to the next yield return statement. * */ foreach (int number in EvenSequence(5, 18)) { Console.WriteLine(number.ToString() + " "); } // Output: 6 8 10 12 14 16 18 Console.WriteLine("_3-------------------------------------------------------------"); /* * In the following example, the DaysOfTheWeek class implements the IEnumerable * interface, which requires a GetEnumerator method. The compiler implicitly * calls the GetEnumerator method, which returns an IEnumerator. */ DaysOfTheWeek days = new DaysOfTheWeek(); foreach (string day in days) { Console.WriteLine(day + " "); } // Output: Sun Mon Tue Wed Thu Fri Sat }
public void GetAttribute_OnDaysOfTheWeek_Success() { DaysOfTheWeek day = DaysOfTheWeek.Monday; Assert.AreEqual<string>("Monday", day.ToString()); Assert.AreEqual<string>("MONDAY", DisplayNameAttribute.Format(day)); }
private static DaysOfTheWeek AddDay(DaysOfTheWeek listofdays, DaysOfTheWeek singleday) { if (!listofdays.HasFlag(singleday)) { return(listofdays | singleday); } return(listofdays); }
/// <summary> /// Creates a MonthlyDowTrigger that fires during specified months only. /// </summary> /// <param name="hour">Hour of day trigger will fire.</param> /// <param name="minutes">Minute of the hour trigger will fire.</param> /// <param name="daysOfTheWeek">Days of the week trigger will fire.</param> /// <param name="whichWeeks">Weeks of the month trigger will fire.</param> /// <param name="months">Months of the year trigger will fire.</param> public MonthlyDowTrigger(short hour, short minutes, DaysOfTheWeek daysOfTheWeek, WhichWeek whichWeeks, MonthsOfTheYear months) : base() { SetStartTime((ushort)hour, (ushort)minutes); taskTrigger.Type = TaskTriggerType.TIME_TRIGGER_MONTHLYDOW; taskTrigger.Data.monthlyDOW.WhichWeek = (ushort)whichWeeks; taskTrigger.Data.monthlyDOW.DaysOfTheWeek = (ushort)daysOfTheWeek; taskTrigger.Data.monthlyDOW.Months = (ushort)months; }
/// <summary> /// Initializes an instance of <see cref="MonthlyWeekPattern"/> class. /// </summary> /// <param name="weekOfMonth">The week of the month when the event occurs.</param> /// <param name="daysOfWeek">The accepted days of the week when the event can occur.</param> /// <param name="interval">The interval of occurrences in number of months.</param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="interval"/> is less than 1.</exception> public MonthlyWeekPattern(WeekOfMonth weekOfMonth, DaysOfTheWeek daysOfWeek, int interval = 1) { Contract.Requires <ArgumentOutOfRangeException>(interval >= 1, nameof(interval)); WeekOfMonth = weekOfMonth; DaysOfWeek = daysOfWeek & DaysOfTheWeek.Any; Interval = interval; }
/// <summary> /// Creates a MonthlyDOWTrigger that fires every month. /// </summary> /// <param name="hour">Hour of day trigger will fire.</param> /// <param name="minutes">Minute of the hour trigger will fire.</param> /// <param name="daysOfTheWeek">Days of the week trigger will fire.</param> /// <param name="whichWeeks">Weeks of the month trigger will fire.</param> /// <param name="months">Months of the year trigger will fire.</param> public MonthlyDOWTrigger(short hour, short minutes, DaysOfTheWeek daysOfTheWeek, WhichWeek whichWeeks, MonthsOfTheYear months) : base() { SetStartTime((ushort)hour, (ushort)minutes); taskTrigger.Type = TaskTriggerType.TIME_TRIGGER_MONTHLYDOW; taskTrigger.Data.monthlyDOW.WhichWeek = (ushort)whichWeeks; taskTrigger.Data.monthlyDOW.DaysOfTheWeek = (ushort)daysOfTheWeek; taskTrigger.Data.monthlyDOW.Months = (ushort)months; }
protected override DaysOfTheWeek Combine(DaysOfTheWeek original, DaysOfTheWeek add, out bool same) { DaysOfTheWeek result = original | add; same = (result == original); return(result); }
public static string Format(DaysOfTheWeek day) { DisplayNameAttribute[] attribute = (DisplayNameAttribute[])typeof(DaysOfTheWeek).GetField( day.ToString()) .GetCustomAttributes(typeof(DisplayNameAttribute), false); return attribute.Count() == 0 ? day.ToString() : attribute.FirstOrDefault().Name; }
private static string GetCultureEquivalentString(DaysOfTheWeek val) { if (val == DaysOfTheWeek.AllDays) { return Resources.DOWAllDays; } var s = new List<string>(7); var vals = Enum.GetValues(val.GetType()); for (var i = 0; i < vals.Length - 1; i++) { if ((val & (DaysOfTheWeek)vals.GetValue(i)) > 0) { s.Add(DateTimeFormatInfo.CurrentInfo.GetDayName((DayOfWeek)i)); } } return string.Join(Resources.ListSeparator, s.ToArray()); }
protected static string DaysToString(DaysOfTheWeek days) { string result = null; foreach (DaysOfTheWeek day in Enum.GetValues(typeof(DaysOfTheWeek))) { if ((day == DaysOfTheWeek.All) || (day == DaysOfTheWeek.None)) continue; if ((days & day) == day) { result += Common.Localize("DayAbbreviation:" + day); } } return result; }
private void SetWeeklyDay(CheckBox cb, DaysOfTheWeek dow) { if (!onAssignment && cb != null) { var weeklyTrigger = (WeeklyTrigger)trigger; if (cb.Checked) weeklyTrigger.DaysOfWeek |= dow; else { // Ensure that ONE day is always checked. if (weeklyTrigger.DaysOfWeek == dow) cb.Checked = true; else weeklyTrigger.DaysOfWeek &= ~dow; } } }
/// <summary> /// Updates a weekly trigger to specify the days of the week on which it will run. /// </summary> /// <param name="dow">The days of the week.</param> /// <returns> /// <see cref="TriggerBuilder" /> instance. /// </returns> public TriggerBuilder On(DaysOfTheWeek dow) { ((WeeklyTrigger)trigger).DaysOfWeek = dow; return this as TriggerBuilder; }
public static bool HasAfterschoolActivityOnDays(SimDescription actor, DaysOfTheWeek daysToCheck) { School school = actor.CareerManager.School; if (school != null) { List<AfterschoolActivity> afterschoolActivities = school.AfterschoolActivities; if (afterschoolActivities != null) { foreach (AfterschoolActivity activity in afterschoolActivities) { if ((activity.DaysForActivity & daysToCheck) != DaysOfTheWeek.None) { return true; } } } } return false; }
public int GetSpeed(DaysOfTheWeek day, int hour, int overrideSpeed) { if (mDisable) { return Relativity.sOneMinute; } if (overrideSpeed > 0) { return overrideSpeed; } int speed = 0; if (mSpeedOverride != 0) { if (mSpeedOverride < 0) { speed = 0; } else { speed = mSpeedOverride; } } else { Dictionary<DaysOfTheWeek, Dictionary<int, int>> days; if ((!Speeds.TryGetValue(GameUtils.GetCurrentWorld(), out days)) && (!Speeds.TryGetValue(WorldName.Undefined, out days))) { speed = Relativity.sOneMinute; } else { Dictionary<int, int> hours; if (!days.TryGetValue(day, out hours)) { speed = Relativity.sOneMinute; } else if (!hours.TryGetValue(hour, out speed)) { speed = Relativity.sOneMinute; } } } int activeSize = Households.NumSims(Household.ActiveHousehold) - mActiveSimFactorMinimum; if (activeSize > 0) { speed -= (int)(speed * activeSize * (mActiveSimFactorReduction / 100f)); if (speed <= 0) { speed = 1; } } return speed; }
public WeeklyTrigger(DaysOfTheWeek daysOfWeek = (DaysOfTheWeek)1, short weeksInterval = 1) : base(TaskTriggerType.Weekly) { DaysOfWeek = daysOfWeek; WeeksInterval = weeksInterval; }
/// <summary> /// Creates an unbound instance of a <see cref="MonthlyDOWTrigger"/>. /// </summary> /// <param name="daysOfWeek">The days of the week.</param> /// <param name="monthsOfYear">The months of the year.</param> /// <param name="weeksOfMonth">The weeks of the month.</param> public MonthlyDOWTrigger(DaysOfTheWeek daysOfWeek = DaysOfTheWeek.Sunday, MonthsOfTheYear monthsOfYear = MonthsOfTheYear.AllMonths, WhichWeek weeksOfMonth = WhichWeek.FirstWeek) : base(TaskTriggerType.MonthlyDOW) { this.DaysOfWeek = daysOfWeek; this.MonthsOfYear = monthsOfYear; this.WeeksOfMonth = weeksOfMonth; }
/// <summary> /// Creates an unbound instance of a <see cref="WeeklyTrigger"/>. /// </summary> /// <param name="daysOfWeek">The days of the week.</param> /// <param name="weeksInterval">The interval between the weeks in the schedule.</param> public WeeklyTrigger(DaysOfTheWeek daysOfWeek = DaysOfTheWeek.Sunday, short weeksInterval = 1) : base(TaskTriggerType.Weekly) { this.DaysOfWeek = daysOfWeek; this.WeeksInterval = weeksInterval; }
internal TriggerBuilder(BuilderInfo taskBuilder, DaysOfTheWeek dow) : this(taskBuilder) { TaskDef.Triggers.Add(trigger = new MonthlyDOWTrigger(dow)); }
/// <summary> /// Creates a WeeklyTrigger that is eligible to fire during any week. /// </summary> /// <param name="hour">Hour of day trigger will fire.</param> /// <param name="minutes">Minutes of hour (specified in "hour") trigger will fire.</param> /// <param name="daysOfTheWeek">Days of the week task will run.</param> public WeeklyTrigger(short hour, short minutes, DaysOfTheWeek daysOfTheWeek) : this(hour, minutes, daysOfTheWeek, 1) { }
internal MonthlyDOWTriggerBuilder(BuilderInfo taskBuilder, DaysOfTheWeek dow) : base(taskBuilder) { this.trb = new TriggerBuilder(taskBuilder, dow); }
/// <summary> /// Adds a trigger that executes monthly on certain days of the week. /// </summary> /// <param name="dow">The days of the week on which to run.</param> /// <returns><see cref="MonthlyDOWTriggerBuilder" /> instance.</returns> public MonthlyDOWTriggerBuilder OnAll(DaysOfTheWeek dow) { return new MonthlyDOWTriggerBuilder(tb, dow); }
/// <summary> /// Creates a MonthlyDOWTrigger that fires during specified months only. /// </summary> /// <param name="hour">Hour of day trigger will fire.</param> /// <param name="minutes">Minute of the hour trigger will fire.</param> /// <param name="daysOfTheWeek">Days of the week trigger will fire.</param> /// <param name="whichWeeks">Weeks of the month trigger will fire.</param> public MonthlyDOWTrigger(short hour, short minutes, DaysOfTheWeek daysOfTheWeek, WhichWeek whichWeeks) : this(hour, minutes, daysOfTheWeek, whichWeeks, MonthsOfTheYear.January|MonthsOfTheYear.February|MonthsOfTheYear.March|MonthsOfTheYear.April|MonthsOfTheYear.May|MonthsOfTheYear.June|MonthsOfTheYear.July|MonthsOfTheYear.August|MonthsOfTheYear.September|MonthsOfTheYear.October|MonthsOfTheYear.November|MonthsOfTheYear.December) { }