Пример #1
0
 private void AddTransitionReferenceInfo(TimeZoneDefinition.TransitionsGroup transitionsGroup)
 {
     if (!string.IsNullOrEmpty(transitionsGroup.Id))
     {
         this.AddParam(transitionsGroup.Name + ".Id", transitionsGroup.Id);
     }
 }
Пример #2
0
 private TimeZoneDefinition.TransitionsGroup ParseTransitionsGroup(XmlElement xmlTransitionGroup, bool checkTransitionsGroup)
 {
     TimeZoneDefinition.TransitionsGroup transitionsGroup = new TimeZoneDefinition.TransitionsGroup(checkTransitionsGroup);
     transitionsGroup.Id          = TimeZoneDefinition.GetAndVerifyNotNullString(xmlTransitionGroup, "Id", (Strings.IDs) 4098403379U, checkTransitionsGroup);
     transitionsGroup.Transitions = this.ParseTransitionArray(xmlTransitionGroup);
     if (checkTransitionsGroup && transitionsGroup.Transitions.Length > 2)
     {
         throw new TimeZoneException((Strings.IDs) 3442221872U, transitionsGroup, transitionsGroup.Transitions[2]);
     }
     return(transitionsGroup);
 }
Пример #3
0
        private void ConvertTransitionsGroups()
        {
            this.transitionsGroups = new TimeZoneDefinition.TransitionsGroup[this.timeZoneDefinitionProxy.TransitionsGroups.Length];
            int num = 0;

            foreach (ArrayOfTransitionsType allTransitions in this.timeZoneDefinitionProxy.TransitionsGroups)
            {
                TimeZoneDefinition.TransitionsGroup container = new TimeZoneDefinition.TransitionsGroup(true);
                this.transitionsGroups[num++] = this.ConvertTransitions(container, allTransitions);
            }
        }
Пример #4
0
        private TimeZoneDefinition.TransitionsGroup ConvertTransitions(TimeZoneDefinition.TransitionsGroup container, ArrayOfTransitionsType allTransitions)
        {
            container.Id          = allTransitions.Id;
            container.Transitions = new TimeZoneDefinition.Transition[allTransitions.Items.Length];
            int num = 0;

            foreach (TransitionType transitionType in allTransitions.Items)
            {
                container.Transitions[num++] = this.ConvertTransition(transitionType);
            }
            return(container);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
 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);
 }
Пример #8
0
 private void ConvertTransitions()
 {
     TimeZoneDefinition.TransitionsGroup container = new TimeZoneDefinition.TransitionsGroup(false);
     this.transitions = this.ConvertTransitions(container, this.timeZoneDefinitionProxy.Transitions);
 }
Пример #9
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);
        }
Пример #10
0
 public TimeZoneException(Enum messageId, TimeZoneDefinition.TransitionsGroup transitionsGroup, TimeZoneDefinition.Transition transition) : this(messageId)
 {
     this.AddTransitionReferenceInfo(transition, transitionsGroup);
 }
Пример #11
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);
 }