// Token: 0x06000881 RID: 2177 RVA: 0x0002ED10 File Offset: 0x0002CF10 internal Recurrence(string s, ComplianceTracker tracker) { this.tracker = tracker; Recurrence.ParserStates parserStates = Recurrence.ParserStates.Name; int length = s.Length; string s2 = string.Empty; List <string> list = new List <string>(); int i = 0; while (i < length) { switch (parserStates) { case Recurrence.ParserStates.Name: { StringBuilder stringBuilder = new StringBuilder(); while (i < length) { char c = s[i++]; if ((int)c >= ContentLineParser.Dictionary.Length || (byte)(ContentLineParser.Dictionary[(int)c] & ContentLineParser.Tokens.ValueChar) == 0) { this.SetComplianceStatus(CalendarStrings.InvalidCharacterInRecurrence); return; } if (c == '=') { break; } stringBuilder.Append(c); } s2 = stringBuilder.ToString(); parserStates = Recurrence.ParserStates.Value; break; } case Recurrence.ParserStates.Value: { bool flag = false; StringBuilder stringBuilder = new StringBuilder(); while (i < length) { char c = s[i++]; if ((int)c >= ContentLineParser.Dictionary.Length || (byte)(ContentLineParser.Dictionary[(int)c] & ContentLineParser.Tokens.ValueChar) == 0) { this.SetComplianceStatus(CalendarStrings.InvalidCharacterInRecurrence); return; } if (c == ';') { flag = true; parserStates = Recurrence.ParserStates.Name; break; } if (c == ',') { flag = false; break; } stringBuilder.Append(c); } list.Add(stringBuilder.ToString()); if (flag || i == length) { int num = list.Count; RecurrenceProperties recurProp = Recurrence.GetRecurProp(s2); if (recurProp <= RecurrenceProperties.ByDay) { if (recurProp <= RecurrenceProperties.BySecond) { switch (recurProp) { case RecurrenceProperties.Frequency: if (num > 1) { this.SetComplianceStatus(CalendarStrings.MultivalueNotPermittedOnFreq); return; } this.freq = Recurrence.GetFrequency(list[0]); if (this.freq == Frequency.Unknown) { this.SetComplianceStatus(CalendarStrings.UnknownFrequencyValue); return; } this.props |= RecurrenceProperties.Frequency; break; case RecurrenceProperties.UntilDate: if (num > 1) { this.SetComplianceStatus(CalendarStrings.MultivalueNotPermittedOnUntil); return; } if ((this.props & RecurrenceProperties.UntilDate) != RecurrenceProperties.None || (this.props & RecurrenceProperties.UntilDateTime) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.UntilOnlyPermittedOnce); return; } if ((this.props & RecurrenceProperties.Count) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.UntilNotPermittedWithCount); return; } if (list[0].Length > 8) { this.untilDateTime = CalendarCommon.ParseDateTime(list[0], tracker); this.props |= RecurrenceProperties.UntilDateTime; } else { this.untilDate = CalendarCommon.ParseDate(list[0], tracker); this.props |= RecurrenceProperties.UntilDate; } break; case RecurrenceProperties.Frequency | RecurrenceProperties.UntilDate: goto IL_A5C; case RecurrenceProperties.Count: if ((this.props & RecurrenceProperties.Count) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.CountOnlyPermittedOnce); return; } if ((this.props & RecurrenceProperties.UntilDate) != RecurrenceProperties.None || (this.props & RecurrenceProperties.UntilDateTime) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.CountNotPermittedWithUntil); return; } if (num > 1) { this.SetComplianceStatus(CalendarStrings.MultivalueNotPermittedOnCount); return; } if (!int.TryParse(list[0], out this.count)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.props |= RecurrenceProperties.Count; break; default: if (recurProp != RecurrenceProperties.Interval) { if (recurProp != RecurrenceProperties.BySecond) { goto IL_A5C; } if ((this.props & RecurrenceProperties.BySecond) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.BySecondOnlyPermittedOnce); return; } this.bySecond = new int[num]; for (int j = 0; j < num; j++) { if (!int.TryParse(list[j], out this.bySecond[j])) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } if (this.bySecond[j] < 0 || this.bySecond[j] > 59) { this.SetComplianceStatus(CalendarStrings.BySecondOutOfRange); return; } } this.props |= RecurrenceProperties.BySecond; } else { if ((this.props & RecurrenceProperties.Interval) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.IntervalOnlyPermittedOnce); return; } if (num > 1) { this.SetComplianceStatus(CalendarStrings.MultivalueNotPermittedOnInterval); return; } if (!int.TryParse(list[0], out this.interval)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } if (this.interval < 1) { this.SetComplianceStatus(CalendarStrings.IntervalMustBePositive); return; } this.props |= RecurrenceProperties.Interval; } break; } } else if (recurProp != RecurrenceProperties.ByMinute) { if (recurProp != RecurrenceProperties.ByHour) { if (recurProp != RecurrenceProperties.ByDay) { goto IL_A5C; } if ((this.props & RecurrenceProperties.ByDay) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByDayOnlyPermittedOnce); return; } this.byDay = new Recurrence.ByDay[num]; for (int k = 0; k < num; k++) { string text = list[k]; if (text.Length != 0) { int num2 = 0; while (num2 < text.Length && text[num2] == ' ') { num2++; } if (num2 != text.Length) { int num3 = num2 - 1; char c2; do { c2 = text[++num3]; if ((int)c2 >= ContentLineParser.Dictionary.Length) { goto Block_53; } }while (((byte)(ContentLineParser.Dictionary[(int)c2] & ContentLineParser.Tokens.Digit) > 0 || c2 == '+' || c2 == '-') && num3 + 1 < text.Length); IL_66C: if (num3 != num2) { int num4 = 0; string s3 = text.Substring(num2, num3 - num2); if (!int.TryParse(s3, out num4) || num4 == 0) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.byDay[k].OccurrenceNumber = num4; } while (text[num3] == ' ' && num3 + 1 < text.Length) { num3++; } this.byDay[k].Day = this.GetDayOfWeek(text.Substring(num3, text.Length - num3)); goto IL_700; Block_53: this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); goto IL_66C; } } IL_700 :; } this.props |= RecurrenceProperties.ByDay; } else { if ((this.props & RecurrenceProperties.ByHour) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByHourOnlyPermittedOnce); return; } this.byHour = new int[num]; for (int l = 0; l < num; l++) { if (!int.TryParse(list[l], out this.byHour[l])) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } if (this.byHour[l] < 0 || this.byHour[l] > 23) { this.SetComplianceStatus(CalendarStrings.ByHourOutOfRange); return; } } this.props |= RecurrenceProperties.ByHour; } } else { if ((this.props & RecurrenceProperties.ByMinute) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByMinuteOnlyPermittedOnce); return; } this.byMinute = new int[num]; for (int m = 0; m < num; m++) { if (!int.TryParse(list[m], out this.byMinute[m])) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } if (this.byMinute[m] < 0 || this.byMinute[m] > 59) { this.SetComplianceStatus(CalendarStrings.ByMinuteOutOfRange); return; } } this.props |= RecurrenceProperties.ByMinute; } } else if (recurProp <= RecurrenceProperties.ByWeek) { if (recurProp != RecurrenceProperties.ByMonthDay) { if (recurProp != RecurrenceProperties.ByYearDay) { if (recurProp != RecurrenceProperties.ByWeek) { goto IL_A5C; } if ((this.props & RecurrenceProperties.ByWeek) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByWeekNoOnlyPermittedOnce); return; } this.byWeekNumber = new int[num]; for (int n = 0; n < num; n++) { int num5; if (!int.TryParse(list[n], out num5)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.byWeekNumber[n] = num5; if (num5 == 0 || num5 > 53 || num5 < -53) { this.SetComplianceStatus(CalendarStrings.ByWeekNoOutOfRange); return; } } this.props |= RecurrenceProperties.ByWeek; } else { if ((this.props & RecurrenceProperties.ByYearDay) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByYearDayOnlyPermittedOnce); return; } this.byYearDay = new int[num]; for (int num6 = 0; num6 < num; num6++) { int num7; if (!int.TryParse(list[num6], out num7)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.byYearDay[num6] = num7; if (num7 == 0 || num7 > 366 || num7 < -366) { this.SetComplianceStatus(CalendarStrings.ByYearDayOutOfRange); return; } } this.props |= RecurrenceProperties.ByYearDay; } } else { if ((this.props & RecurrenceProperties.ByMonthDay) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByMonthDayOnlyPermittedOnce); return; } this.byMonthDay = new int[num]; for (int num8 = 0; num8 < num; num8++) { int num9; if (!int.TryParse(list[num8], out num9)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.byMonthDay[num8] = num9; if (num9 == 0 || num9 > 31 || num9 < -31) { this.SetComplianceStatus(CalendarStrings.ByMonthDayOutOfRange); return; } } this.props |= RecurrenceProperties.ByMonthDay; } } else if (recurProp != RecurrenceProperties.ByMonth) { if (recurProp != RecurrenceProperties.BySetPosition) { if (recurProp != RecurrenceProperties.WeekStart) { goto IL_A5C; } if ((this.props & RecurrenceProperties.WeekStart) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.WkStOnlyPermittedOnce); return; } if (num > 1) { this.SetComplianceStatus(CalendarStrings.MultivalueNotPermittedOnWkSt); return; } this.workWeekStart = this.GetDayOfWeek(list[0]); this.props |= RecurrenceProperties.WeekStart; } else { if ((this.props & RecurrenceProperties.BySetPosition) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.BySetPosOnlyPermittedOnce); return; } this.bySetPos = new int[num]; for (int num10 = 0; num10 < num; num10++) { int num11; if (!int.TryParse(list[num10], out num11)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.bySetPos[num10] = num11; if (num11 == 0 || num11 > 366 || num11 < -366) { this.SetComplianceStatus(CalendarStrings.BySetPosOutOfRange); return; } } this.props |= RecurrenceProperties.BySetPosition; } } else { if ((this.props & RecurrenceProperties.ByMonth) != RecurrenceProperties.None) { this.SetComplianceStatus(CalendarStrings.ByMonthOnlyPermittedOnce); return; } this.byMonth = new int[num]; for (int num12 = 0; num12 < num; num12++) { int num13; if (!int.TryParse(list[num12], out num13)) { this.SetComplianceStatus(CalendarStrings.InvalidValueFormat); } this.byMonth[num12] = num13; if (num13 < 0 || num13 > 12) { this.SetComplianceStatus(CalendarStrings.ByMonthOutOfRange); return; } } this.props |= RecurrenceProperties.ByMonth; } IL_A67: list = new List <string>(); break; IL_A5C: this.SetComplianceStatus(CalendarStrings.UnknownRecurrenceProperty); goto IL_A67; } break; } } } }
// Token: 0x060008A2 RID: 2210 RVA: 0x0002FA0C File Offset: 0x0002DC0C public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); if ((this.props & RecurrenceProperties.Frequency) != RecurrenceProperties.None) { stringBuilder.Append("FREQ"); stringBuilder.Append('='); stringBuilder.Append(Recurrence.GetFrequencyString(this.freq)); } if ((this.props & RecurrenceProperties.UntilDate) != RecurrenceProperties.None) { stringBuilder.Append(";UNTIL"); stringBuilder.Append('='); stringBuilder.Append(CalendarCommon.FormatDate(this.untilDate)); } if ((this.props & RecurrenceProperties.UntilDateTime) != RecurrenceProperties.None) { stringBuilder.Append(";UNTIL"); stringBuilder.Append('='); stringBuilder.Append(CalendarCommon.FormatDateTime(this.untilDateTime)); } if ((this.props & RecurrenceProperties.Count) != RecurrenceProperties.None) { stringBuilder.Append(";COUNT"); stringBuilder.Append('='); stringBuilder.Append(this.count); } if ((this.props & RecurrenceProperties.Interval) != RecurrenceProperties.None) { stringBuilder.Append(";INTERVAL"); stringBuilder.Append('='); stringBuilder.Append(this.interval); } if ((this.props & RecurrenceProperties.BySecond) != RecurrenceProperties.None) { stringBuilder.Append(";BYSECOND"); stringBuilder.Append('='); this.OutputList(this.bySecond, stringBuilder); } if ((this.props & RecurrenceProperties.ByMinute) != RecurrenceProperties.None) { stringBuilder.Append(";BYMINUTE"); stringBuilder.Append('='); this.OutputList(this.byMinute, stringBuilder); } if ((this.props & RecurrenceProperties.ByHour) != RecurrenceProperties.None) { stringBuilder.Append(";BYHOUR"); stringBuilder.Append('='); this.OutputList(this.byHour, stringBuilder); } if ((this.props & RecurrenceProperties.ByDay) != RecurrenceProperties.None) { stringBuilder.Append(";BYDAY"); stringBuilder.Append('='); int num = this.byDay.Length; if (num > 0) { stringBuilder.Append(this.byDay[0]); } for (int i = 1; i < num; i++) { stringBuilder.Append(','); stringBuilder.Append(this.byDay[i].ToString()); } } if ((this.props & RecurrenceProperties.ByMonthDay) != RecurrenceProperties.None) { stringBuilder.Append(";BYMONTHDAY"); stringBuilder.Append('='); this.OutputList(this.byMonthDay, stringBuilder); } if ((this.props & RecurrenceProperties.ByYearDay) != RecurrenceProperties.None) { stringBuilder.Append(";BYYEARDAY"); stringBuilder.Append('='); this.OutputList(this.byYearDay, stringBuilder); } if ((this.props & RecurrenceProperties.ByWeek) != RecurrenceProperties.None) { stringBuilder.Append(";BYWEEKNO"); stringBuilder.Append('='); this.OutputList(this.byWeekNumber, stringBuilder); } if ((this.props & RecurrenceProperties.ByMonth) != RecurrenceProperties.None) { stringBuilder.Append(";BYMONTH"); stringBuilder.Append('='); this.OutputList(this.byMonth, stringBuilder); } if ((this.props & RecurrenceProperties.BySetPosition) != RecurrenceProperties.None) { stringBuilder.Append(";BYSETPOS"); stringBuilder.Append('='); this.OutputList(this.bySetPos, stringBuilder); } if ((this.props & RecurrenceProperties.WeekStart) != RecurrenceProperties.None) { stringBuilder.Append(";WKST"); stringBuilder.Append('='); stringBuilder.Append(Recurrence.GetDayOfWeekString(this.workWeekStart)); } return(stringBuilder.ToString()); }
internal void WritePropertyValue(object value, CalendarValueSeparators separator) { if (value == null) { throw new ArgumentNullException("value"); } CalendarValueType calendarValueType = this.valueType; if (calendarValueType <= CalendarValueType.Float) { if (calendarValueType <= CalendarValueType.Date) { switch (calendarValueType) { case CalendarValueType.Unknown: break; case CalendarValueType.Binary: { byte[] array = value as byte[]; if (array == null) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.PrepareStartPropertyValue(ContentLineParser.Separators.None); this.writer.WriteToStream(array); this.EndProperty(); return; } case CalendarValueType.Unknown | CalendarValueType.Binary: goto IL_276; case CalendarValueType.Boolean: if (!(value is bool)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((bool)value, separator); return; default: if (calendarValueType != CalendarValueType.CalAddress) { if (calendarValueType != CalendarValueType.Date) { goto IL_276; } if (!(value is DateTime)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((DateTime)value, CalendarValueType.Date, separator); return; } break; } } else if (calendarValueType != CalendarValueType.DateTime) { if (calendarValueType != CalendarValueType.Duration) { if (calendarValueType != CalendarValueType.Float) { goto IL_276; } if (!(value is float)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((float)value, separator); return; } else { if (!(value is TimeSpan)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((TimeSpan)value, CalendarValueType.Duration, separator); return; } } else { if (!(value is DateTime)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((DateTime)value, separator); return; } } else if (calendarValueType <= CalendarValueType.Recurrence) { if (calendarValueType != CalendarValueType.Integer) { if (calendarValueType != CalendarValueType.Period) { if (calendarValueType != CalendarValueType.Recurrence) { goto IL_276; } Recurrence recurrence = value as Recurrence; if (recurrence == null) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue(recurrence); return; } else { if (!(value is CalendarPeriod)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((CalendarPeriod)value, separator); return; } } else { if (!(value is int)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((int)value, separator); return; } } else if (calendarValueType <= CalendarValueType.Time) { if (calendarValueType != CalendarValueType.Text) { if (calendarValueType != CalendarValueType.Time) { goto IL_276; } if (!(value is CalendarTime)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((CalendarTime)value, separator); return; } } else if (calendarValueType != CalendarValueType.Uri) { if (calendarValueType != CalendarValueType.UtcOffset) { goto IL_276; } if (!(value is TimeSpan)) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue((TimeSpan)value, CalendarValueType.UtcOffset, separator); return; } string text = value as string; if (text == null) { throw new ArgumentException(CalendarStrings.InvalidValueTypeForProperty); } this.WritePropertyValue(text, separator); return; IL_276: throw new InvalidDataException(CalendarStrings.InvalidValueTypeForProperty); }