simple test
Мелкий тест.
Ниже длинный исходник на C#. Определить — WTF он или нет и предположить, зачем он нужен. Завтра выложу полный исходник с объяснениями.
[cc lang=»csharp»]
[Flags]
public enum Month
{
January = 0x1,
February = 0x2,
March = 0x4,
April = 0x8,
May = 0x10,
Juny = 0x20,
July = 0x40,
August = 0x80,
September = 0x100,
October = 0x200,
November = 0x400,
December = 0x800,
}
[Flags]
public enum FlaggingDayOfWeek
{
Monday = 0x1,
Tuesday = 0x2,
Wednesday = 0x4,
Thursday = 0x8,
Friday = 0x10,
Saturday = 0x20,
Sunday = 0x40,
}
[Flags]
public enum Days
{
d1 = 0x1,
d2 = 0x2,
d3 = 0x4,
d4 = 0x8,
d5 = 0x10,
d6 = 0x20,
d7 = 0x40,
d8 = 0x80,
d9 = 0x100,
d10 = 0x200,
d11 = 0x400,
d12 = 0x800,
d13 = 0x1000,
d14 = 0x2000,
d15 = 0x4000,
d16 = 0x8000,
d17 = 0x10000,
d18 = 0x20000,
d19 = 0x40000,
d20 = 0x80000,
d21 = 0x100000,
d22 = 0x200000,
d23 = 0x400000,
d24 = 0x800000,
d25 = 0x1000000,
d26 = 0x2000000,
d27 = 0x4000000,
d28 = 0x8000000,
d29 = 0x10000000,
d30 = 0x20000000,
d31 = 0x40000000,
}
public class Schedule
{
#region Cache
public const FlaggingDayOfWeek AllDaysOfWeek = FlaggingDayOfWeek.Monday | FlaggingDayOfWeek.Tuesday |
FlaggingDayOfWeek.Wednesday | FlaggingDayOfWeek.Thursday | FlaggingDayOfWeek.Friday |
FlaggingDayOfWeek.Saturday | FlaggingDayOfWeek.Sunday;
public const Month AllMonthes =
Month.January | Month.February | Month.March |
Month.April | Month.May | Month.Juny |
Month.July | Month.August | Month.September |
Month.October | Month.November | Month.December;
public const Days AllDays =
Days.d1 | Days.d2 | Days.d3 | Days.d4 | Days.d5 | Days.d6 | Days.d7 |
Days.d8 | Days.d9 | Days.d10 | Days.d11 | Days.d12 | Days.d13 | Days.d14 |
Days.d15 | Days.d16 | Days.d17 | Days.d18 | Days.d19 | Days.d20 | Days.d21 |
Days.d22 | Days.d23 | Days.d24 | Days.d25 | Days.d26 | Days.d27 | Days.d28 |
Days.d29 | Days.d30 | Days.d31;
private static readonly Dictionary
{
{ DayOfWeek.Monday, FlaggingDayOfWeek.Monday },
{ DayOfWeek.Tuesday, FlaggingDayOfWeek.Tuesday },
{ DayOfWeek.Wednesday, FlaggingDayOfWeek.Wednesday },
{ DayOfWeek.Thursday, FlaggingDayOfWeek.Thursday },
{ DayOfWeek.Friday, FlaggingDayOfWeek.Friday },
{ DayOfWeek.Saturday, FlaggingDayOfWeek.Saturday },
{ DayOfWeek.Sunday, FlaggingDayOfWeek.Sunday },
};
private static readonly Dictionary
{
{ 1, Month.January },
{ 2, Month.February },
{ 3, Month.March },
{ 4, Month.April },
{ 5, Month.May },
{ 6, Month.Juny },
{ 7, Month.July },
{ 8, Month.August },
{ 9, Month.September },
{ 10, Month.October },
{ 11, Month.November },
{ 12, Month.December },
};
private static readonly Dictionary
{
{ 1, Days.d1 },
{ 2, Days.d2 },
{ 3, Days.d3 },
{ 4, Days.d4 },
{ 5, Days.d5 },
{ 6, Days.d6 },
{ 7, Days.d7 },
{ 8, Days.d8 },
{ 9, Days.d9 },
{ 10, Days.d10 },
{ 11, Days.d11 },
{ 12, Days.d12 },
{ 13, Days.d13 },
{ 14, Days.d14 },
{ 15, Days.d15 },
{ 16, Days.d16 },
{ 17, Days.d17 },
{ 18, Days.d18 },
{ 19, Days.d19 },
{ 20, Days.d20 },
{ 21, Days.d21 },
{ 22, Days.d22 },
{ 23, Days.d23 },
{ 24, Days.d24 },
{ 25, Days.d25 },
{ 26, Days.d26 },
{ 27, Days.d27 },
{ 28, Days.d28 },
{ 29, Days.d29 },
{ 30, Days.d30 },
{ 31, Days.d31 },
};
#endregion
public FlaggingDayOfWeek EnabledDaysOfWeek { get; set; }
public Month EnabledMonthes { get; set; }
public Days EnabledDays { get; set; }
[XmlIgnore]
public TimeSpan StartTime { get; set; }
[XmlIgnore]
public TimeSpan Interval { get; set; }
public int? Count { get; set; }
[XmlElement(DataType = «duration», ElementName = «StartTime»)]
public string FakeStartTime
{
get { return StartTime.ToString(); }
set { StartTime = TimeSpan.Parse(value); }
}
[XmlElement(DataType = «duration», ElementName = «Interval»)]
public string FakeInterval
{
get { return Interval.ToString(); }
set { Interval = TimeSpan.Parse(value); }
}
}
[/cc]
[…] в предыдущей записи действительно смахивает на WTF, но он таким, имхо, не […]