private void AddRulesToRuleGroup(ExTimeZoneRuleGroup timeZoneRuleGroup, TimeZoneDefinition.Transition transition, TimeZoneDefinition.TransitionsGroup transitions)
 {
     if (transition.To.Kind != TimeZoneDefinition.TransitionTargetKindType.Group)
     {
         throw new TimeZoneException((Strings.IDs) 2265146620U, transitions, transition);
     }
     foreach (TimeZoneDefinition.TransitionsGroup transitionsGroup in this.transitionsGroups)
     {
         if (transitionsGroup.Id == transition.To.Value)
         {
             int num = transitionsGroup.Transitions.Length;
             for (int j = 0; j < num; j++)
             {
                 int num2 = (j + 1) % num;
                 TimeZoneDefinition.Transition transition2          = transitionsGroup.Transitions[j];
                 TimeZoneDefinition.Transition transitionFromPeriod = transitionsGroup.Transitions[num2];
                 if (transition2.To.Kind != TimeZoneDefinition.TransitionTargetKindType.Period)
                 {
                     throw new TimeZoneException(Strings.IDs.MessageInvalidTimeZoneReferenceToPeriod, transitionsGroup, transition2);
                 }
                 this.AddRuleToRuleGroup(timeZoneRuleGroup, transition2, transitionFromPeriod, transitionsGroup);
             }
             return;
         }
     }
     throw new TimeZoneException(Strings.IDs.MessageInvalidTimeZoneMissedGroup, transitions, transition);
 }
Esempio n. 2
0
        private void AddTransitionReferenceInfo(TimeZoneDefinition.Transition transition, TimeZoneDefinition.TransitionsGroup transitionsGroup)
        {
            string text = transitionsGroup.Name + "." + TimeZoneException.TransitionTypeToString(transition) + ".To";

            this.AddTransitionReferenceInfo(transitionsGroup);
            this.AddParam(text + ".Kind", transition.To.Kind.ToString());
            this.AddParam(text, transition.To.Value);
        }
Esempio n. 3
0
 private static string TransitionTypeToString(TimeZoneDefinition.Transition transition)
 {
     if (transition != null)
     {
         transition.GetType();
         return(transition.GetType().Name);
     }
     return("UnknownTansition");
 }
        private void AddRuleToRuleGroup(ExTimeZoneRuleGroup timeZoneRuleGroup, TimeZoneDefinition.Transition transitionToPeriod, TimeZoneDefinition.Transition transitionFromPeriod, TimeZoneDefinition.TransitionsGroup transitionToGroup)
        {
            TimeZoneDefinition.RecurringDayTransition  recurringDayTransition  = transitionFromPeriod as TimeZoneDefinition.RecurringDayTransition;
            TimeZoneDefinition.RecurringDateTransition recurringDateTransition = transitionFromPeriod as TimeZoneDefinition.RecurringDateTransition;
            if (!this.periodsDictionary.ContainsKey(transitionToPeriod.To.Value))
            {
                throw new TimeZoneException((Strings.IDs) 3865092385U, transitionToGroup, transitionToPeriod);
            }
            TimeZoneDefinition.PeriodType periodType = this.periodsDictionary[transitionToPeriod.To.Value];
            TimeSpan bias = XmlConvert.ToTimeSpan(periodType.Bias);

            bias = bias.Negate();
            ExYearlyRecurringTime observanceEnd;

            if (recurringDateTransition != null)
            {
                TimeSpan timeSpan = TimeZoneDefinition.ConvertOffsetToTimeSpan(recurringDateTransition.TimeOffset, transitionToPeriod, transitionToGroup);
                try
                {
                    observanceEnd = new ExYearlyRecurringDate(recurringDateTransition.Month, recurringDateTransition.Day, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds);
                    goto IL_16C;
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    throw new TimeZoneException((Strings.IDs) 3961981453U, ex, transitionToGroup, transitionToPeriod, "ParameterName", ex.ParamName);
                }
            }
            if (recurringDayTransition != null)
            {
                TimeSpan  timeSpan2 = TimeZoneDefinition.ConvertOffsetToTimeSpan(recurringDayTransition.TimeOffset, transitionToPeriod, transitionToGroup);
                DayOfWeek?dayOfWeek = this.ConvertToDayOfWeek(recurringDayTransition.DayOfWeek);
                if (dayOfWeek == null)
                {
                    throw new TimeZoneException(Strings.IDs.MessageInvalidTimeZoneDayOfWeekValue, transitionToGroup, transitionToPeriod);
                }
                try
                {
                    observanceEnd = new ExYearlyRecurringDay(recurringDayTransition.Occurrence, dayOfWeek.Value, recurringDayTransition.Month, timeSpan2.Hours, timeSpan2.Minutes, timeSpan2.Seconds, timeSpan2.Milliseconds);
                    goto IL_16C;
                }
                catch (ArgumentOutOfRangeException ex2)
                {
                    throw new TimeZoneException((Strings.IDs) 3961981453U, ex2, transitionToGroup, transitionToPeriod, "ParameterName", ex2.ParamName);
                }
            }
            observanceEnd = null;
IL_16C:
            ExTimeZoneRule ruleInfo = new ExTimeZoneRule(periodType.Id, periodType.Name, bias, observanceEnd);

            timeZoneRuleGroup.AddRule(ruleInfo);
        }
        private static TimeSpan ConvertOffsetToTimeSpan(string timeOffset, TimeZoneDefinition.Transition transitionToPeriod, TimeZoneDefinition.TransitionsGroup transitionToGroup)
        {
            TimeSpan result;

            try
            {
                result = XmlConvert.ToTimeSpan(timeOffset);
            }
            catch (FormatException innerException)
            {
                throw new TimeZoneException(Strings.IDs.MessageInvalidTimeZoneInvalidOffsetFormat, innerException, transitionToGroup, transitionToPeriod);
            }
            return(result);
        }
        private TimeZoneDefinition.Transition[] ParseTransitionArray(XmlElement xmlTransitions)
        {
            int count = xmlTransitions.ChildNodes.Count;

            TimeZoneDefinition.Transition[] array = new TimeZoneDefinition.Transition[count];
            int num = 0;

            foreach (object obj in xmlTransitions.ChildNodes)
            {
                XmlElement xmlTransition = (XmlElement)obj;
                array[num] = this.ParseTransitionElement(xmlTransition);
                num++;
            }
            return(array);
        }
Esempio n. 7
0
 public TimeZoneException(Enum messageId, TimeZoneDefinition.TransitionsGroup transitionsGroup, TimeZoneDefinition.Transition transition) : this(messageId)
 {
     this.AddTransitionReferenceInfo(transition, transitionsGroup);
 }
Esempio n. 8
0
 public TimeZoneException(Enum messageId, Exception innerException, TimeZoneDefinition.TransitionsGroup transitionsGroup, TimeZoneDefinition.Transition transition, string param, string paramValue) : this(messageId, innerException)
 {
     this.AddParam(param, paramValue);
     this.AddTransitionReferenceInfo(transition, transitionsGroup);
 }