コード例 #1
0
        /// <summary>
        /// Converts the flags to "day of week" enum list.
        /// </summary>
        /// <param name="flags">The flags.</param>
        /// <returns></returns>
        public static List <DayOfWeek> AsDayOfWeekList(this DayOfWeekFlag flags)
        {
            var enums = new List <DayOfWeek>();

            if ((flags & DayOfWeekFlag.Sunday) == DayOfWeekFlag.Sunday)
            {
                enums.Add(DayOfWeek.Sunday);
            }

            if ((flags & DayOfWeekFlag.Monday) == DayOfWeekFlag.Monday)
            {
                enums.Add(DayOfWeek.Monday);
            }

            if ((flags & DayOfWeekFlag.Tuesday) == DayOfWeekFlag.Tuesday)
            {
                enums.Add(DayOfWeek.Tuesday);
            }

            if ((flags & DayOfWeekFlag.Wednesday) == DayOfWeekFlag.Wednesday)
            {
                enums.Add(DayOfWeek.Wednesday);
            }

            if ((flags & DayOfWeekFlag.Thursday) == DayOfWeekFlag.Thursday)
            {
                enums.Add(DayOfWeek.Thursday);
            }

            if ((flags & DayOfWeekFlag.Friday) == DayOfWeekFlag.Friday)
            {
                enums.Add(DayOfWeek.Friday);
            }

            if ((flags & DayOfWeekFlag.Saturday) == DayOfWeekFlag.Saturday)
            {
                enums.Add(DayOfWeek.Saturday);
            }

            return(enums);
        }
コード例 #2
0
ファイル: DayOfWeekFlagUtils.cs プロジェクト: liquidsnk/Aspid
        /// <summary>
        /// Gets the list of day of week represented by the flag.
        /// </summary>
        /// <param name="days">The days.</param>
        /// <returns></returns>
        public static IList<DayOfWeek> GetDayOfWeekList(DayOfWeekFlag daysFlag)
        {
            var list = new List<DayOfWeek>();

            if (daysFlag == DayOfWeekFlag.None) return list;

            foreach (var day in EnumUtils.GetElements<DayOfWeek>())
            {
                if (ContainsDay(daysFlag, day))
                {
                    list.Add(day);
                }
            }

            return list;
        }
コード例 #3
0
ファイル: DayOfWeekFlagUtils.cs プロジェクト: liquidsnk/Aspid
 /// <summary>
 /// Determines whether the specified days flag contains the given days.
 /// </summary>
 /// <param name="daysFlag">The days flag.</param>
 /// <param name="days">The days.</param>
 /// <returns>
 /// 	<c>true</c> if the specified days flag contains the given days; otherwise, <c>false</c>.
 /// </returns>
 public static bool ContainsDays(DayOfWeekFlag daysFlag, params DayOfWeek[] days)
 {
     if (daysFlag == DayOfWeekFlag.None) return false;
     var givenDaysFlag = FromDaysOfWeek(days);
     return EnumUtils.ContainsElement(daysFlag, givenDaysFlag);
 }
コード例 #4
0
ファイル: DayOfWeekFlagUtils.cs プロジェクト: liquidsnk/Aspid
 /// <summary>
 /// Determines whether the specified days flag contains the given day.
 /// </summary>
 /// <param name="daysFlag">The days flag.</param>
 /// <param name="day">The day.</param>
 /// <returns>
 /// 	<c>true</c> if the specified days flag contains the given day; otherwise, <c>false</c>.
 /// </returns>
 public static bool ContainsDay(DayOfWeekFlag daysFlag, DayOfWeek day)
 {
     return ContainsDays(daysFlag, day);
 }