Beispiel #1
0
        // Token: 0x0600074A RID: 1866 RVA: 0x00028BD4 File Offset: 0x00026DD4
        public void WriteParameterValue(string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            this.AssertValidState(WriteState.Parameter);
            if (this.firstParameterValue)
            {
                this.writer.WriteStartValue();
                this.firstParameterValue = false;
            }
            else
            {
                this.writer.WriteNextValue(ContentLineParser.Separators.Comma);
            }
            if (this.parameter == ParameterId.ValueType && value.Length > 0)
            {
                this.valueType = CalendarCommon.GetValueTypeEnum(value);
            }
            bool flag = this.IsQuotingRequired(value);

            if (flag)
            {
                this.writer.WriteToStream(34);
            }
            this.writer.WriteToStream(value);
            if (flag)
            {
                this.writer.WriteToStream(34);
            }
        }
Beispiel #2
0
        internal CalendarPeriod(string s, ComplianceTracker tracker)
        {
            int num = s.IndexOf('/');

            if (num <= 0 || s.Length - 1 == num)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidTimeFormat);
                this.start            = CalendarCommon.MinDateTime;
                this.end              = CalendarCommon.MinDateTime;
                this.duration         = TimeSpan.Zero;
                this.isExplicitPeriod = false;
                return;
            }
            DateTime dateTime = CalendarCommon.ParseDateTime(s.Substring(0, num), tracker);
            char     c        = s[num + 1];

            if (c == '+' || c == '-' || c == 'P')
            {
                TimeSpan t = CalendarCommon.ParseDuration(s.Substring(num + 1), tracker);
                this.start            = dateTime;
                this.end              = dateTime + t;
                this.duration         = t;
                this.isExplicitPeriod = false;
                return;
            }
            DateTime d = CalendarCommon.ParseDateTime(s.Substring(num + 1), tracker);

            this.start            = dateTime;
            this.end              = d;
            this.duration         = dateTime - d;
            this.isExplicitPeriod = true;
        }
Beispiel #3
0
        public static TimeSpan ParseUtcOffset(string s, ComplianceTracker tracker)
        {
            int num    = 0;
            int num2   = 0;
            int num3   = 0;
            int length = s.Length;

            if (length != 5 && length != 7)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidUtcOffsetLength);
                return(TimeSpan.Zero);
            }
            char c = s[0];
            bool flag;

            if (c == '+')
            {
                flag = false;
            }
            else
            {
                if (c != '-')
                {
                    tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedPlusMinus);
                    return(TimeSpan.Zero);
                }
                flag = true;
            }
            for (int i = 1; i < length; i++)
            {
                c = s[i];
                if ((int)c >= ContentLineParser.Dictionary.Length)
                {
                    tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                    return(TimeSpan.Zero);
                }
                if ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) == 0)
                {
                    tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidToken);
                    return(TimeSpan.Zero);
                }
            }
            if (!int.TryParse(s.Substring(1, 2), out num) || num < 0 || num > 23)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
            }
            if (!int.TryParse(s.Substring(3, 2), out num2) || num2 < 0 || num2 > 59)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
            }
            if (length == 7 && (!int.TryParse(s.Substring(5, 2), out num3) || num3 < 0 || num3 > 59))
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
            }
            if (num == 0 && num2 == 0 && num3 == 0 && flag)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
            }
            return(CalendarCommon.CreateTimeSpan(tracker, 0, num, num2, num3, flag));
        }
Beispiel #4
0
 private void CalculateValueType()
 {
     if (this.isValueTypeInitialized)
     {
         return;
     }
     this.valueType = CalendarValueType.Unknown;
     if (this.valueTypeParameter != null)
     {
         this.valueType = CalendarCommon.GetValueTypeEnum(this.valueTypeParameter);
     }
     else
     {
         PropertyId propertyEnum = CalendarCommon.GetPropertyEnum(this.propertyName);
         if (propertyEnum != PropertyId.Unknown)
         {
             this.valueType = CalendarCommon.GetDefaultValueType(propertyEnum);
         }
     }
     if (this.valueType == CalendarValueType.Unknown)
     {
         this.valueType = CalendarValueType.Text;
     }
     this.isValueTypeInitialized = true;
 }
Beispiel #5
0
 // Token: 0x06000744 RID: 1860 RVA: 0x00028A39 File Offset: 0x00026C39
 public void StartComponent(ComponentId componentId)
 {
     if (componentId == ComponentId.Unknown || componentId == ComponentId.None)
     {
         throw new ArgumentException(CalendarStrings.InvalidComponentId);
     }
     this.StartComponent(CalendarCommon.GetComponentString(componentId));
 }
Beispiel #6
0
        // Token: 0x06000747 RID: 1863 RVA: 0x00028B18 File Offset: 0x00026D18
        public void StartProperty(PropertyId propertyId)
        {
            string propertyString = CalendarCommon.GetPropertyString(propertyId);

            if (propertyString == null)
            {
                throw new ArgumentException(CalendarStrings.InvalidPropertyId);
            }
            this.StartProperty(propertyString);
        }
Beispiel #7
0
        // Token: 0x06000749 RID: 1865 RVA: 0x00028BA8 File Offset: 0x00026DA8
        public void StartParameter(ParameterId parameterId)
        {
            string parameterString = CalendarCommon.GetParameterString(parameterId);

            if (parameterString == null)
            {
                throw new ArgumentException(CalendarStrings.InvalidParameterId);
            }
            this.StartParameter(parameterString);
        }
Beispiel #8
0
        // Token: 0x06000715 RID: 1813 RVA: 0x00028264 File Offset: 0x00026464
        private TimeSpan ReadValueAsTimeSpan(CalendarValueSeparators?expectedSeparators)
        {
            this.reader.AssertValidState(ContentLineNodeType.Parameter | ContentLineNodeType.Property);
            string s = this.ReadValueAsString(expectedSeparators).Trim();

            if (CalendarValueType.UtcOffset == this.ValueType)
            {
                return(CalendarCommon.ParseUtcOffset(s, this.reader.ComplianceTracker));
            }
            this.CheckType(CalendarValueType.Duration);
            return(CalendarCommon.ParseDuration(s, this.reader.ComplianceTracker));
        }
Beispiel #9
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(CalendarCommon.FormatDateTime(this.start));
            stringBuilder.Append('/');
            if (this.isExplicitPeriod)
            {
                stringBuilder.Append(CalendarCommon.FormatDateTime(this.end));
            }
            else
            {
                stringBuilder.Append(CalendarCommon.FormatDuration(this.duration));
            }
            return(stringBuilder.ToString());
        }
Beispiel #10
0
        // Token: 0x06000712 RID: 1810 RVA: 0x000281BC File Offset: 0x000263BC
        private DateTime ReadValueAsDateTime(CalendarValueType valueType, CalendarValueSeparators?expectedSeparators)
        {
            this.reader.AssertValidState(ContentLineNodeType.Parameter | ContentLineNodeType.Property);
            string s = this.ReadValueAsString(expectedSeparators).Trim();

            if (CalendarValueType.DateTime == valueType || CalendarValueType.Text == valueType)
            {
                this.CheckType(CalendarValueType.DateTime);
                return(CalendarCommon.ParseDateTime(s, this.reader.ComplianceTracker));
            }
            if (CalendarValueType.Date == valueType)
            {
                this.CheckType(CalendarValueType.Date);
                return(CalendarCommon.ParseDate(s, this.reader.ComplianceTracker));
            }
            throw new ArgumentOutOfRangeException("valueType");
        }
Beispiel #11
0
 // Token: 0x06000748 RID: 1864 RVA: 0x00028B44 File Offset: 0x00026D44
 public void StartParameter(string name)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (this.validate && name.Length == 0)
     {
         throw new ArgumentException();
     }
     this.EndParameter();
     this.AssertValidState(WriteState.Property);
     this.parameter = CalendarCommon.GetParameterEnum(name);
     this.writer.StartParameter(name);
     this.firstParameterValue = true;
     this.state = WriteState.Parameter;
 }
Beispiel #12
0
        // Token: 0x06000769 RID: 1897 RVA: 0x000292F8 File Offset: 0x000274F8
        private void WritePropertyValue(DateTime value, CalendarValueType valueType, CalendarValueSeparators separator)
        {
            string value2;

            if (CalendarValueType.DateTime == valueType || CalendarValueType.Text == valueType)
            {
                value2 = CalendarCommon.FormatDateTime(value);
            }
            else
            {
                if (CalendarValueType.Date != valueType)
                {
                    throw new ArgumentOutOfRangeException("valueType");
                }
                value2 = CalendarCommon.FormatDate(value);
            }
            this.WritePropertyValue(value2, separator);
        }
Beispiel #13
0
 // Token: 0x06000743 RID: 1859 RVA: 0x000289C0 File Offset: 0x00026BC0
 public void StartComponent(string name)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (this.validate && name.Length == 0)
     {
         throw new ArgumentException();
     }
     this.EndProperty();
     this.AssertValidState(WriteState.Start | WriteState.Component);
     this.Save();
     this.componentName = name.ToUpper();
     this.componentId   = CalendarCommon.GetComponentEnum(name);
     this.writer.WriteProperty("BEGIN", this.componentName);
     this.state = WriteState.Component;
 }
Beispiel #14
0
        public static DateTime ParseDateTime(string s, ComplianceTracker tracker)
        {
            int length = s.Length;

            if (length != 15 && length != 16)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidDateTimeLength);
                return(CalendarCommon.MinDateTime);
            }
            DateTime dateTime = CalendarCommon.ParseDate(s.Substring(0, 8), tracker);

            if (s[8] != 'T')
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedTAfterDate);
                return(CalendarCommon.MinDateTime);
            }
            CalendarTime calendarTime = new CalendarTime(s.Substring(9), tracker);

            return(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, calendarTime.Time.Hours, calendarTime.Time.Minutes, calendarTime.Time.Seconds, calendarTime.IsUtc ? DateTimeKind.Utc : DateTimeKind.Unspecified));
        }
Beispiel #15
0
        // Token: 0x06000746 RID: 1862 RVA: 0x00028A8C File Offset: 0x00026C8C
        public void StartProperty(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (this.validate && name.Length == 0)
            {
                throw new ArgumentException();
            }
            this.EndProperty();
            this.AssertValidState(WriteState.Component);
            PropertyId propertyEnum = CalendarCommon.GetPropertyEnum(name);

            this.propertyName = name.ToUpper();
            this.property     = propertyEnum;
            this.Save();
            this.valueType = CalendarCommon.GetDefaultValueType(propertyEnum);
            this.writer.StartProperty(this.propertyName);
            this.firstPropertyValue = true;
            this.state = WriteState.Property;
        }
Beispiel #16
0
        // Token: 0x0600076A RID: 1898 RVA: 0x0002933C File Offset: 0x0002753C
        private void WritePropertyValue(TimeSpan value, CalendarValueType valueType, CalendarValueSeparators separator)
        {
            string value2;

            if (CalendarValueType.Duration == valueType)
            {
                value2 = CalendarCommon.FormatDuration(value);
            }
            else
            {
                if (CalendarValueType.UtcOffset != valueType)
                {
                    throw new ArgumentOutOfRangeException("valueType");
                }
                if (value.Days > 0 && this.validate)
                {
                    throw new ArgumentException(CalendarStrings.UtcOffsetTimespanCannotContainDays, "value");
                }
                value2 = CalendarCommon.FormatUtcOffset(value);
            }
            this.WritePropertyValue(value2, separator);
        }
Beispiel #17
0
        // 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;
                }
                }
            }
        }
Beispiel #18
0
        public static TimeSpan ParseDuration(string s, ComplianceTracker tracker)
        {
            int num    = 0;
            int length = s.Length;

            CalendarCommon.DurationParseStates durationParseStates = CalendarCommon.DurationParseStates.Start;
            StringBuilder stringBuilder = null;
            int           num2          = 0;
            int           num3          = 0;
            int           hours         = 0;
            int           minutes       = 0;
            int           seconds       = 0;
            bool          negative      = false;

            while (num < length && durationParseStates != CalendarCommon.DurationParseStates.End)
            {
                char c = s[num];
                if ((int)c >= ContentLineParser.Dictionary.Length)
                {
                    tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                    return(TimeSpan.Zero);
                }
                switch (durationParseStates)
                {
                case CalendarCommon.DurationParseStates.Start:
                    if (c == 'P')
                    {
                        durationParseStates = CalendarCommon.DurationParseStates.S1;
                    }
                    else if (c == '+')
                    {
                        durationParseStates = CalendarCommon.DurationParseStates.Sign;
                    }
                    else
                    {
                        if (c != '-')
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                        negative            = true;
                        durationParseStates = CalendarCommon.DurationParseStates.Sign;
                    }
                    break;

                case CalendarCommon.DurationParseStates.Sign:
                    if (c != 'P')
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedP);
                        return(TimeSpan.Zero);
                    }
                    durationParseStates = CalendarCommon.DurationParseStates.S1;
                    break;

                case CalendarCommon.DurationParseStates.S1:
                    if ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) != 0)
                    {
                        stringBuilder = new StringBuilder();
                        stringBuilder.Append(c);
                        durationParseStates = CalendarCommon.DurationParseStates.S2;
                    }
                    else
                    {
                        if (c != 'T')
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                        durationParseStates = CalendarCommon.DurationParseStates.T1;
                    }
                    break;

                case CalendarCommon.DurationParseStates.S2:
                    while ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) != 0)
                    {
                        stringBuilder.Append(c);
                        if (++num == length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedWOrD);
                            return(TimeSpan.Zero);
                        }
                        c = s[num];
                        if ((int)c >= ContentLineParser.Dictionary.Length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                    }
                    if (c == 'W')
                    {
                        if (!int.TryParse(stringBuilder.ToString(), out num3))
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                        }
                        durationParseStates = CalendarCommon.DurationParseStates.End;
                    }
                    else
                    {
                        if (c != 'D')
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                        if (!int.TryParse(stringBuilder.ToString(), out num2))
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                        }
                        durationParseStates = CalendarCommon.DurationParseStates.D1;
                    }
                    break;

                case CalendarCommon.DurationParseStates.D1:
                    if (c != 'T')
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedT);
                        return(TimeSpan.Zero);
                    }
                    durationParseStates = CalendarCommon.DurationParseStates.T1;
                    break;

                case CalendarCommon.DurationParseStates.T1:
                    if ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) == 0)
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                        return(TimeSpan.Zero);
                    }
                    stringBuilder = new StringBuilder();
                    stringBuilder.Append(c);
                    durationParseStates = CalendarCommon.DurationParseStates.T2;
                    break;

                case CalendarCommon.DurationParseStates.T2:
                    while ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) != 0)
                    {
                        stringBuilder.Append(c);
                        if (++num == length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedHMS);
                            return(TimeSpan.Zero);
                        }
                        c = s[num];
                        if ((int)c >= ContentLineParser.Dictionary.Length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                    }
                    if (c == 'H')
                    {
                        if (!int.TryParse(stringBuilder.ToString(), out hours))
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                        }
                        durationParseStates = CalendarCommon.DurationParseStates.H1;
                    }
                    else if (c == 'M')
                    {
                        if (!int.TryParse(stringBuilder.ToString(), out minutes))
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                        }
                        durationParseStates = CalendarCommon.DurationParseStates.M1;
                    }
                    else
                    {
                        if (c != 'S')
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                        if (!int.TryParse(stringBuilder.ToString(), out seconds))
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                        }
                        durationParseStates = CalendarCommon.DurationParseStates.End;
                    }
                    break;

                case CalendarCommon.DurationParseStates.H1:
                    if ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) == 0)
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                        return(TimeSpan.Zero);
                    }
                    stringBuilder = new StringBuilder();
                    stringBuilder.Append(c);
                    durationParseStates = CalendarCommon.DurationParseStates.H2;
                    break;

                case CalendarCommon.DurationParseStates.H2:
                    while ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) != 0)
                    {
                        stringBuilder.Append(c);
                        if (++num == length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedM);
                            return(TimeSpan.Zero);
                        }
                        c = s[num];
                        if ((int)c >= ContentLineParser.Dictionary.Length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                    }
                    if (c != 'M')
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                        return(TimeSpan.Zero);
                    }
                    if (!int.TryParse(stringBuilder.ToString(), out minutes))
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                    }
                    durationParseStates = CalendarCommon.DurationParseStates.M1;
                    break;

                case CalendarCommon.DurationParseStates.M1:
                    if ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) == 0)
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                        return(TimeSpan.Zero);
                    }
                    stringBuilder = new StringBuilder();
                    stringBuilder.Append(c);
                    durationParseStates = CalendarCommon.DurationParseStates.M2;
                    break;

                case CalendarCommon.DurationParseStates.M2:
                    while ((byte)(ContentLineParser.Tokens.Digit & ContentLineParser.Dictionary[(int)c]) != 0)
                    {
                        stringBuilder.Append(c);
                        if (++num == length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.ExpectedS);
                            return(TimeSpan.Zero);
                        }
                        c = s[num];
                        if ((int)c >= ContentLineParser.Dictionary.Length)
                        {
                            tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                            return(TimeSpan.Zero);
                        }
                    }
                    if (c != 'S')
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidCharacter);
                        return(TimeSpan.Zero);
                    }
                    if (!int.TryParse(stringBuilder.ToString(), out seconds))
                    {
                        tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                    }
                    durationParseStates = CalendarCommon.DurationParseStates.End;
                    break;

                default:
                    tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.InvalidValueFormat);
                    return(TimeSpan.Zero);
                }
                num++;
            }
            if (num != length)
            {
                tracker.SetComplianceStatus(ComplianceStatus.InvalidValueFormat, CalendarStrings.DurationDataNotEndedProperly);
                return(TimeSpan.Zero);
            }
            if (num3 != 0)
            {
                num2 += num3 * 7;
            }
            return(CalendarCommon.CreateTimeSpan(tracker, num2, hours, minutes, seconds, negative));
        }
Beispiel #19
0
        // 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());
        }