Esempio n. 1
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            TimeZoneNameProperty o = new TimeZoneNameProperty();

            o.Clone(this);
            return(o);
        }
Esempio n. 2
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            TimeZoneNameProperty o = new TimeZoneNameProperty();
            o.Clone(this);
            return o;
        }
Esempio n. 3
0
        /// <summary>
        /// This is implemented to handle properties related to observance rule items in VTimeZone objects
        /// </summary>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="parameters">A string collection containing the parameters and their values.  If empty,
        /// there are no parameters.</param>
        /// <param name="propertyValue">The value of the property.</param>
        protected virtual void ObservanceRuleParser(string propertyName, StringCollection parameters, string propertyValue)
        {
            StringCollection sc;
            string[] parts, parms;
            int idx;

            // The last entry is always CustomProperty so scan for length minus one
            for(idx = 0; idx < ntvORule.Length - 1; idx++)
                if(ntvORule[idx].IsMatch(propertyName))
                    break;

            // An opening BEGIN:STANDARD or BEGIN:DAYLIGHT property must have been seen.
            if(obsRule == null)
                throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp",
                        "BEGIN:STANDARD/BEGIN:DAYLIGHT", propertyName));

            // Handle or create the property
            switch(ntvORule[idx].EnumValue)
            {
                case PropertyType.Begin:    // Handle unknown nested objects
                    priorState.Push(currentState);
                    currentState = VCalendarParserState.Custom;
                    CustomObjectParser(propertyName, parameters, propertyValue);
                    break;

                case PropertyType.End:
                    // For this, the value must be STANDARD or DAYLIGHT depending on the rule type
                    if((obsRule.RuleType == ObservanceRuleType.Standard &&
                      String.Compare(propertyValue.Trim(), "STANDARD", StringComparison.OrdinalIgnoreCase) != 0) ||
                      (obsRule.RuleType == ObservanceRuleType.Daylight &&
                      String.Compare(propertyValue.Trim(), "DAYLIGHT", StringComparison.OrdinalIgnoreCase) != 0))
                    {
                        throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue",
                            ntvORule[idx].Name, propertyValue));
                    }

                    // The rule is added to the collection when created so we don't have to rely on an END tag to
                    // add it.
                    obsRule = null;
                    currentState = priorState.Pop();
                    break;

                case PropertyType.StartDateTime:
                    obsRule.StartDateTime.DeserializeParameters(parameters);
                    obsRule.StartDateTime.EncodedValue = propertyValue;
                    break;

                case PropertyType.TimeZoneOffsetFrom:
                    obsRule.OffsetFrom.DeserializeParameters(parameters);
                    obsRule.OffsetFrom.EncodedValue = propertyValue;
                    break;

                case PropertyType.TimeZoneOffsetTo:
                    obsRule.OffsetTo.DeserializeParameters(parameters);
                    obsRule.OffsetTo.EncodedValue = propertyValue;
                    break;

                case PropertyType.Comment:
                    // If this is seen more than once, just add the new stuff to the existing property
                    if(obsRule.Comment.Value != null)
                    {
                        obsRule.Comment.EncodedValue += "\r\n";
                        obsRule.Comment.EncodedValue += propertyValue;
                    }
                    else
                    {
                        obsRule.Comment.DeserializeParameters(parameters);
                        obsRule.Comment.EncodedValue = propertyValue;
                    }
                    break;

                case PropertyType.RecurrenceRule:
                    RRuleProperty rr = new RRuleProperty();
                    rr.DeserializeParameters(parameters);
                    rr.EncodedValue = propertyValue;
                    obsRule.RecurrenceRules.Add(rr);
                    break;

                case PropertyType.RecurDate:
                    // There may be more than one date in the value.  If so, split them into separate ones.  This
                    // makes it easier to manage.  They'll get written back out as individual properties but
                    // that's okay.
                    parts = propertyValue.Split(',', ';');

                    // It's important that we retain the same parameters for each one
                    parms = new string[parameters.Count];
                    parameters.CopyTo(parms, 0);

                    foreach(string s in parts)
                    {
                        sc = new StringCollection();
                        sc.AddRange(parms);

                        RDateProperty rd = new RDateProperty();
                        rd.DeserializeParameters(sc);
                        rd.EncodedValue = s;

                        obsRule.RecurDates.Add(rd);
                    }
                    break;

                case PropertyType.TimeZoneName:
                    TimeZoneNameProperty tzn = new TimeZoneNameProperty();
                    tzn.DeserializeParameters(parameters);
                    tzn.EncodedValue = propertyValue;
                    obsRule.TimeZoneNames.Add(tzn);
                    break;

                default:    // Anything else is a custom property
                    CustomProperty cust = new CustomProperty(propertyName);
                    cust.DeserializeParameters(parameters);
                    cust.EncodedValue = propertyValue;
                    obsRule.CustomProperties.Add(cust);
                    break;
            }
        }