public HolidayYearEvent(DateTime date, Holiday holiday, int length) { Date = date; Holiday = holiday; Length = length; }
private static void LoadHolidays() { string id = ""; try { var doc = new XmlDocument(); doc.Load(AppSettings.GetDataPath() + "\\holidays.xml"); XmlElement root = doc.DocumentElement; XmlNodeList holidaysList = root?.SelectNodes("//holiday"); if (holidaysList != null) foreach (XmlElement element in holidaysList) { string uid = element.Attributes["uid"].Value; string name = element.Attributes["name"].Value; id = name; var type = (Holiday.HolidayType) Enum.Parse(typeof (Holiday.HolidayType), element.Attributes["type"].Value); var traveltype = (Holiday.TravelType) Enum.Parse(typeof (Holiday.TravelType), element.Attributes["holidaytype"].Value); var countries = new List<Country>(); XmlNodeList countriesList = element.SelectNodes("observers/observer"); if (countriesList != null) countries.AddRange(from XmlElement eCountry in countriesList select Countries.GetCountry(eCountry.Attributes["country"].Value)); var dateElement = (XmlElement) element.SelectSingleNode("observationdate"); if (type == Holiday.HolidayType.FixedDate) { if (dateElement != null) { int month = Convert.ToInt16(dateElement.Attributes["month"].Value); int day = Convert.ToInt16(dateElement.Attributes["day"].Value); var date = new DateTime(1900, month, day); foreach (Country country in countries) { var holiday = new Holiday(root.Name, uid, type, name, traveltype, country) {Date = date}; Holidays.AddHoliday(holiday); } } } if (type == Holiday.HolidayType.FixedMonth) { if (dateElement != null) { int month = Convert.ToInt16(dateElement.Attributes["month"].Value); foreach (Country country in countries) { var holiday = new Holiday(root.Name, uid, type, name, traveltype, country) {Month = month}; Holidays.AddHoliday(holiday); } } } if (type == Holiday.HolidayType.FixedWeek) { if (dateElement != null) { int week = Convert.ToInt16(dateElement.Attributes["week"].Value); foreach (Country country in countries) { var holiday = new Holiday(root.Name, uid, type, name, traveltype, country) {Week = week}; Holidays.AddHoliday(holiday); } } } if (type == Holiday.HolidayType.NonFixedDate) { if (dateElement != null) { int month = Convert.ToInt16(dateElement.Attributes["month"].Value); int week = Convert.ToInt16(dateElement.Attributes["week"].Value); var day = (DayOfWeek) Enum.Parse(typeof (DayOfWeek), dateElement.Attributes["dayofweek"].Value); foreach (Country country in countries) { var holiday = new Holiday(root.Name, uid, type, name, traveltype, country) {Month = month, Week = week, Day = day}; Holidays.AddHoliday(holiday); } } } if (element.SelectSingleNode("translations") != null) { Translator.GetInstance() .AddTranslation( root.Name, element.Attributes["uid"].Value, element.SelectSingleNode("translations")); } } } catch (Exception e) { Logger.Error("Error loading holiday {0}", id); Logger.Error(e); } }
public static void AddHoliday(Holiday holiday) { holidays.Add(holiday); }