Пример #1
0
        /// <summary>
        /// Ranges to json.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <returns></returns>
        private object RangeToJson(ExchangeService service)
        {
            RecurrenceRange range;

            if (!this.HasEnd)
            {
                range = new NoEndRecurrenceRange(this.StartDate);
            }
            else if (this.NumberOfOccurrences.HasValue)
            {
                range = new NumberedRecurrenceRange(this.StartDate, this.NumberOfOccurrences);
            }
            else
            {
                range = new EndDateRecurrenceRange(this.StartDate, this.EndDate.Value);
            }

            return(range.InternalToJson(service));
        }
        /// <summary>
        /// Gets the recurrence range.
        /// </summary>
        /// <param name="recurrenceRangeString">The recurrence range string.</param>
        /// <returns></returns>
        private static RecurrenceRange GetRecurrenceRange(string recurrenceRangeString)
        {
            RecurrenceRange range;

            switch (recurrenceRangeString)
            {
            case XmlElementNames.NoEndRecurrence:
                range = new NoEndRecurrenceRange();
                break;

            case XmlElementNames.EndDateRecurrence:
                range = new EndDateRecurrenceRange();
                break;

            case XmlElementNames.NumberedRecurrence:
                range = new NumberedRecurrenceRange();
                break;

            default:
                throw new ServiceXmlDeserializationException(string.Format(Strings.InvalidRecurrenceRange, recurrenceRangeString));
            }
            return(range);
        }
Пример #3
0
        /// <summary>
        /// Writes elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override sealed void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Types, this.XmlElementName);
            this.InternalWritePropertiesToXml(writer);
            writer.WriteEndElement();

            RecurrenceRange range;

            if (!this.HasEnd)
            {
                range = new NoEndRecurrenceRange(this.StartDate);
            }
            else if (this.NumberOfOccurrences.HasValue)
            {
                range = new NumberedRecurrenceRange(this.StartDate, this.NumberOfOccurrences);
            }
            else
            {
                range = new EndDateRecurrenceRange(this.StartDate, this.EndDate.Value);
            }

            range.WriteToXml(writer, range.XmlElementName);
        }
        /// <summary>
        /// Gets the recurrence range.
        /// </summary>
        /// <param name="recurrenceRangeString">The recurrence range string.</param>
        /// <returns></returns>
        private static RecurrenceRange GetRecurrenceRange(string recurrenceRangeString)
        {
            RecurrenceRange range;

            switch (recurrenceRangeString)
            {
                case XmlElementNames.NoEndRecurrence:
                    range = new NoEndRecurrenceRange();
                    break;
                case XmlElementNames.EndDateRecurrence:
                    range = new EndDateRecurrenceRange();
                    break;
                case XmlElementNames.NumberedRecurrence:
                    range = new NumberedRecurrenceRange();
                    break;
                default:
                    throw new ServiceXmlDeserializationException(string.Format(Strings.InvalidRecurrenceRange, recurrenceRangeString));
            }
            return range;
        }