/// <summary>Initializes a new instance of the <see cref="ImportedHolidayCalendar"/> class.
 /// </summary>
 /// <param name="calendarName">The name of the calendar.</param>
 /// <param name="holidayCalendarRegion">The region with respect to the holiday calendar.</param>
 /// <param name="firstDate">The earliest date for which holiday informations are available.</param>
 /// <param name="lastDate">The lastest date for which holiday informations are available.</param>
 /// <param name="holidayCollection">The list of holidays.</param>
 /// <param name="listOfHolidayNames">The (optional) list of holiday names.</param>
 /// <param name="annotation">The (optional) annotation (= description) of the holiday calendar.</param>
 /// <param name="weekendRepresentation">The weekend representation, if <c>null</c> Saturdays and Sundays are always non-working days.</param>
 public ImportedHolidayCalendar(IdentifierString calendarName, HolidayCalendarRegion holidayCalendarRegion, DateTime firstDate, DateTime lastDate, IList <DateTime> holidayCollection, IList <string> listOfHolidayNames = null, string annotation = null, IWeekendRepresentation weekendRepresentation = null)
     : this(calendarName, holidayCalendarRegion, firstDate, lastDate, weekendRepresentation)
 {
     if (holidayCollection == null)
     {
         throw new ArgumentNullException("holidayCollection");
     }
     if ((listOfHolidayNames != null) && (holidayCollection.Count != listOfHolidayNames.Count))
     {
         throw new ArgumentException("The number of holidays is destinct from the number of holiday names.", "listOfHolidays");
     }
     for (int i = 0; i <= holidayCollection.Count; i++)
     {
         DateTime holiday = holidayCollection[i];
         if (m_WeekendRepresentation.Contains(holiday.DayOfWeek) == false)
         {
             int year = holiday.Year;
             if (m_ListOfHolidays.ContainsKey(year) == false)
             {
                 m_ListOfHolidays.Add(year, new HashSet <DateInfo>());
             }
             if (listOfHolidayNames != null)
             {
                 m_ListOfHolidays[year].Add(new DateInfo(holiday, listOfHolidayNames[i]));
             }
             else
             {
                 m_ListOfHolidays[year].Add(new DateInfo(holiday));
             }
         }
     }
     m_Annotation = (annotation == null) ? String.Empty : annotation;
 }
 /// <summary>Initializes a new instance of the <see cref="CustomHolidayCalendarAttribute"/> class.
 /// </summary>
 /// <param name="calendarName">The name of the holiday calendar.</param>
 /// <param name="region">The region of the holiday calendar.</param>
 /// <param name="fullResourceName">The name of the resource (including the namespace).</param>
 public CustomHolidayCalendarAttribute(string calendarName, HolidayCalendarRegion region, string fullResourceName)
 {
     CalendarName     = calendarName;
     Region           = region;
     FullResourceName = fullResourceName;
     m_FirstDate      = DateTime.MinValue;
     m_LastDate       = DateTime.MaxValue;
 }
Ejemplo n.º 3
0
 /// <summary>Initializes a new instance of the <see cref="CustomHolidayCalendar"/> class.
 /// </summary>
 /// <param name="calendarName">The name of the calendar.</param>
 /// <param name="region">The region with respect to the holiday calendar.</param>
 /// <param name="holidayCollection">The reference (shallow copy) of the holiday collection.</param>
 /// <param name="firstDate">The earliest date for which holiday informations are available.</param>
 /// <param name="lastDate">The lastest date for which holiday informations are available.</param>
 /// <param name="annotation">The (optional) annotation, i.e. description, of the holiday calendar.</param>
 /// <param name="weekendRepresentation">The weekend representation, if <c>null</c> Saturdays and Sundays are always non-working days.</param>
 /// <exception cref="ArgumentNullException">Thrown, if <paramref name="calendarName"/> or <paramref name="holidayCollection"/> is <c>null</c>.</exception>
 public CustomHolidayCalendar(IdentifierString calendarName, HolidayCalendarRegion region, IEnumerable <IHoliday> holidayCollection, DateTime firstDate, DateTime lastDate, string annotation = null, IWeekendRepresentation weekendRepresentation = null)
     : base(calendarName, region, firstDate, lastDate, (weekendRepresentation == null) ? WeekendFactory.StandardWeekend : weekendRepresentation)
 {
     if (holidayCollection == null)
     {
         throw new ArgumentNullException("holidayCollection");
     }
     HolidayCollection = holidayCollection;
     m_Annotation      = (annotation == null) ? String.Empty : annotation;
 }
Ejemplo n.º 4
0
        /// <summary>Gets the region with respect to a collection of holiday calendars, i.e. the region represents the union of each single region.
        /// </summary>
        /// <param name="holidayCalendarCollection">The holiday calendar collection.</param>
        /// <returns>The region with respect to <paramref name="holidayCalendarCollection"/>, i.e. the <see cref="HolidayCalendarRegion"/>
        /// that is defined by the bitwise operation of each region.</returns>
        private static HolidayCalendarRegion GetRegion(IEnumerable <IHolidayCalendar> holidayCalendarCollection)
        {
            HolidayCalendarRegion region = HolidayCalendarRegion.Unspecified;

            if (holidayCalendarCollection != null)
            {
                foreach (IHolidayCalendar holidayCalendar in holidayCalendarCollection)
                {
                    region |= holidayCalendar.Region;
                }
            }
            return(region);
        }
Ejemplo n.º 5
0
        /// <summary>Gets the region with respect to two holiday calendars, i.e. the region represents the union of each single region.
        /// </summary>
        /// <param name="holidayCalendar1">The first holiday calendar.</param>
        /// <param name="holidayCalendar2">The second holiday calendar.</param>
        /// <returns>The region with respect to the given holiday calendar, i.e. the <see cref="HolidayCalendarRegion"/>
        /// which is given by the bitwise operation of each region.</returns>
        private static HolidayCalendarRegion GetRegion(IHolidayCalendar holidayCalendar1, IHolidayCalendar holidayCalendar2)
        {
            HolidayCalendarRegion region = HolidayCalendarRegion.Unspecified;

            if (holidayCalendar1 != null)
            {
                region |= holidayCalendar1.Region;
            }
            if (holidayCalendar2 != null)
            {
                region |= holidayCalendar2.Region;
            }
            return(region);
        }
Ejemplo n.º 6
0
 /// <summary>Gets the collection of holiday calendars with respect to a specific region.
 /// </summary>
 /// <param name="region">The region.</param>
 /// <returns>The collection of <see cref="IHolidayCalendar"/> instances with respect to <paramref name="region"/>.</returns>
 public static IEnumerable <IHolidayCalendar> GetCalendars(HolidayCalendarRegion region)
 {
     OnInitialize();
     if (region != HolidayCalendarRegion.Unspecified)
     {
         return(from holidayCalendar in sm_Pool.Values
                where (holidayCalendar.Region & region) == region
                select holidayCalendar);
     }
     else  // region = 0x00
     {
         return(from holidayCalendar in sm_Pool.Values
                where holidayCalendar.Region == region
                select holidayCalendar);
     }
 }
 /// <summary>Initializes a new instance of the <see cref="ImportedHolidayCalendar"/> class.
 /// </summary>
 /// <param name="calendarName">The name of the calendar.</param>
 /// <param name="holidayCalendarRegion">The region of the holiday calendar.</param>
 /// <param name="firstDate">The earliest date for which holiday informations are available.</param>
 /// <param name="lastDate">The lastest date for which holiday informations are available.</param>
 /// <param name="weekendRepresentation">The representation of the weekend.</param>
 /// <exception cref="ArgumentNullException">Thrown, if <paramref name="calendarName"/> is <c>null</c>.</exception>
 private ImportedHolidayCalendar(IdentifierString calendarName, HolidayCalendarRegion holidayCalendarRegion, DateTime firstDate, DateTime lastDate, IWeekendRepresentation weekendRepresentation)
 {
     Region = holidayCalendarRegion;
     if (calendarName == null)
     {
         throw new ArgumentNullException("calendarName");
     }
     Name = calendarName;
     if (firstDate < lastDate)
     {
         FirstDate = firstDate;
         LastDate  = lastDate;
     }
     else
     {
         LastDate  = firstDate;
         FirstDate = firstDate;
     }
     m_WeekendRepresentation = (weekendRepresentation == null) ? WeekendFactory.StandardWeekend : weekendRepresentation;
     // m_Logger = Logger.Stream.Create("Imported Holiday Calendar", typeof(ImportedHolidayCalendar), calendarName.String, "Holiday calendar");
 }
 /// <summary>Initializes a new instance of the <see cref="ImportedHolidayCalendar"/> class.
 /// </summary>
 /// <param name="calendarName">The name of the calendar.</param>
 /// <param name="holidayCalendarRegion">The region with respect to the holiday calendar.</param>
 /// <param name="firstDate">The earliest date for which holiday informations are available.</param>
 /// <param name="lastDate">The lastest date for which holiday informations are available.</param>
 /// <param name="listOfHolidays">The list of holidays.</param>
 /// <param name="annotation">The (optional) annotation (= description) of the holiday calendar.</param>
 /// <param name="weekendRepresentation">The weekend representation, if <c>null</c> Saturdays and Sundays are always non-working days.</param>
 public ImportedHolidayCalendar(IdentifierString calendarName, HolidayCalendarRegion holidayCalendarRegion, DateTime firstDate, DateTime lastDate, IEnumerable <DateInfo> listOfHolidays, string annotation = null, IWeekendRepresentation weekendRepresentation = null)
     : this(calendarName, holidayCalendarRegion, firstDate, lastDate, weekendRepresentation)
 {
     if (listOfHolidays == null)
     {
         throw new ArgumentNullException("listOfHolidays");
     }
     foreach (DateInfo holiday in listOfHolidays)
     {
         if (m_WeekendRepresentation.Contains(holiday.DayOfWeek) == false)
         {
             int year = holiday.Year;
             if (m_ListOfHolidays.ContainsKey(year) == false)
             {
                 m_ListOfHolidays.Add(year, new HashSet <DateInfo>());
             }
             m_ListOfHolidays[year].Add(holiday);
         }
     }
     m_Annotation = (annotation == null) ? String.Empty : annotation;
 }
Ejemplo n.º 9
0
 /// <summary>Initializes a new instance of the <see cref="BasicHolidayCalendar"/> class.
 /// </summary>
 /// <param name="calendarName">The name of the calendar.</param>
 /// <param name="region">The region of the holiday calendar.</param>
 /// <param name="firstDate">The earliest date for which holiday informations are available.</param>
 /// <param name="lastDate">The lastest date for which holiday informations are available.</param>
 /// <param name="weekendRepresentation">The representation of the weekend.</param>
 /// <exception cref="ArgumentNullException">Thrown, if <paramref name="calendarName"/> or <paramref name="weekendRepresentation"/> is <c>null</c>.</exception>
 protected BasicHolidayCalendar(IdentifierString calendarName, HolidayCalendarRegion region, DateTime firstDate, DateTime lastDate, IWeekendRepresentation weekendRepresentation)
 {
     Region = region;
     if (calendarName == null)
     {
         throw new ArgumentNullException("calendarName");
     }
     Name = calendarName;
     if (firstDate < lastDate)
     {
         FirstDate = firstDate;
         LastDate  = lastDate;
     }
     else
     {
         LastDate  = firstDate;
         FirstDate = firstDate;
     }
     if (weekendRepresentation == null)
     {
         throw new ArgumentNullException("weekendRepresentation");
     }
     m_WeekendRepresentation = weekendRepresentation;
 }
Ejemplo n.º 10
0
 ///<summary>Creates a new <see cref="IHolidayCalendar"/> object.</summary>
 /// <param name="calendarName">The name of the calendar.</param>
 /// <param name="holidayCalendarRegion">The region with respect to the holiday calendar.</param>
 /// <param name="holidayList">The reference (shallow copy) of the list of holidays taken into account for the holiday calendar.</param>
 /// <param name="annotation">The (optional) annotation, i.e. description, of the holiday calendar.</param>
 /// <param name="weekendRepresentation">The weekend representation, if <c>null</c> Saturdays and Sundays are always non-working days.</param>
 /// <exception cref="ArgumentNullException">Thrown, if <paramref name="calendarName"/> or <paramref name="holidayList"/> is <c>null</c>.</exception>
 /// <returns>A <see cref="IHolidayCalendar"/> object with respect to the list of holidays.</returns>
 /// <remarks>
 /// <see cref="IHolidayCalendar.FirstDate"/> will be set to <see cref="System.DateTime.MinValue"/> and <see cref="IHolidayCalendar.LastDate"/> will
 /// be set to <see cref="System.DateTime.MaxValue"/>.
 /// </remarks>
 public static IHolidayCalendar Create(IdentifierString calendarName, HolidayCalendarRegion holidayCalendarRegion, IEnumerable <IHoliday> holidayList, string annotation = null, IWeekendRepresentation weekendRepresentation = null)
 {
     return(new CustomHolidayCalendar(calendarName, holidayCalendarRegion, holidayList, DateTime.MinValue, DateTime.MaxValue, annotation, weekendRepresentation));
 }