コード例 #1
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if appropriate element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
            case XmlElementNames.TimeZone:
                LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone();
                legacyTimeZone.LoadFromXml(reader, reader.LocalName);

                this.timeZone = legacyTimeZone.ToTimeZoneInfo();

                return(true);

            case XmlElementNames.WorkingPeriodArray:
                List <WorkingPeriod> workingPeriods = new List <WorkingPeriod>();

                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.WorkingPeriod))
                    {
                        WorkingPeriod workingPeriod = new WorkingPeriod();

                        workingPeriod.LoadFromXml(reader, reader.LocalName);

                        workingPeriods.Add(workingPeriod);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.WorkingPeriodArray));

                // Availability supports a structure that can technically represent different working
                // times for each day of the week. This is apparently how the information is stored in
                // Exchange. However, no client (Outlook, OWA) either will let you specify different
                // working times for each day of the week, and Outlook won't either honor that complex
                // structure if it happens to be in Exchange.
                // So here we'll do what Outlook and OWA do: we'll use the start and end times of the
                // first working period, but we'll use the week days of all the periods.
                this.startTime = workingPeriods[0].StartTime;
                this.endTime   = workingPeriods[0].EndTime;

                foreach (WorkingPeriod workingPeriod in workingPeriods)
                {
                    foreach (DayOfTheWeek dayOfWeek in workingPeriods[0].DaysOfWeek)
                    {
                        if (!this.daysOfTheWeek.Contains(dayOfWeek))
                        {
                            this.daysOfTheWeek.Add(dayOfWeek);
                        }
                    }
                }

                return(true);

            default:
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if appropriate element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
                case XmlElementNames.TimeZone:
                    LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone();
                    legacyTimeZone.LoadFromXml(reader, reader.LocalName);

                    this.timeZone = legacyTimeZone.ToTimeZoneInfo();
                    
                    return true;
                case XmlElementNames.WorkingPeriodArray:
                    List<WorkingPeriod> workingPeriods = new List<WorkingPeriod>();

                    do
                    {
                        reader.Read();

                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.WorkingPeriod))
                        {
                            WorkingPeriod workingPeriod = new WorkingPeriod();

                            workingPeriod.LoadFromXml(reader, reader.LocalName);

                            workingPeriods.Add(workingPeriod);
                        }
                    }
                    while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.WorkingPeriodArray));

                    // Availability supports a structure that can technically represent different working
                    // times for each day of the week. This is apparently how the information is stored in
                    // Exchange. However, no client (Outlook, OWA) either will let you specify different
                    // working times for each day of the week, and Outlook won't either honor that complex
                    // structure if it happens to be in Exchange.
                    // So here we'll do what Outlook and OWA do: we'll use the start and end times of the
                    // first working period, but we'll use the week days of all the periods.
                    this.startTime = workingPeriods[0].StartTime;
                    this.endTime = workingPeriods[0].EndTime;

                    foreach (WorkingPeriod workingPeriod in workingPeriods)
                    {
                        foreach (DayOfTheWeek dayOfWeek in workingPeriods[0].DaysOfWeek)
                        {
                            if (!this.daysOfTheWeek.Contains(dayOfWeek))
                            {
                                this.daysOfTheWeek.Add(dayOfWeek);
                            }
                        }
                    }

                    return true;
                default:
                    return false;
            }
        }
コード例 #3
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            // Only serialize the TimeZone property against an Exchange 2007 SP1 server.
            // Against Exchange 2010, the time zone is emitted in the request's SOAP header.
            if (writer.Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1)
            {
                LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone(writer.Service.TimeZone);

                legacyTimeZone.WriteToXml(writer, XmlElementNames.TimeZone);
            }

            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.MailboxDataArray);

            foreach (AttendeeInfo attendee in this.Attendees)
            {
                attendee.WriteToXml(writer);
            }

            writer.WriteEndElement(); // MailboxDataArray

            this.Options.WriteToXml(writer, this);
        }
コード例 #4
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            // Only serialize the TimeZone property against an Exchange 2007 SP1 server.
            // Against Exchange 2010, the time zone is emitted in the request's SOAP header.
            if (writer.Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1)
            {
                LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone(writer.Service.TimeZone);

                legacyTimeZone.WriteToXml(writer, XmlElementNames.TimeZone);
            }

            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.MailboxDataArray);

            foreach (AttendeeInfo attendee in this.Attendees)
            {
                attendee.WriteToXml(writer);
            }

            writer.WriteEndElement(); // MailboxDataArray

            this.Options.WriteToXml(writer, this);
        }
コード例 #5
0
        /// <summary>
        /// Loads from json.
        /// </summary>
        /// <param name="jsonProperty">The json property.</param>
        /// <param name="service">The service.</param>
        internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service)
        {
            foreach (string key in jsonProperty.Keys)
            {
                switch (key)
                {
                case XmlElementNames.TimeZone:
                    LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone();
                    legacyTimeZone.LoadFromJson(jsonProperty.ReadAsJsonObject(key), service);

                    this.timeZone = legacyTimeZone.ToTimeZoneInfo();

                    break;

                case XmlElementNames.WorkingPeriodArray:
                    List <WorkingPeriod> workingPeriods = new List <WorkingPeriod>();

                    object[] workingPeriodsArray = jsonProperty.ReadAsArray(key);

                    foreach (object workingPeriodEntry in workingPeriodsArray)
                    {
                        JsonObject jsonWorkingPeriodEntry = workingPeriodEntry as JsonObject;

                        if (jsonWorkingPeriodEntry != null)
                        {
                            WorkingPeriod workingPeriod = new WorkingPeriod();

                            workingPeriod.LoadFromJson(jsonWorkingPeriodEntry, service);

                            workingPeriods.Add(workingPeriod);
                        }
                    }

                    // Availability supports a structure that can technically represent different working
                    // times for each day of the week. This is apparently how the information is stored in
                    // Exchange. However, no client (Outlook, OWA) either will let you specify different
                    // working times for each day of the week, and Outlook won't either honor that complex
                    // structure if it happens to be in Exchange.
                    // So here we'll do what Outlook and OWA do: we'll use the start and end times of the
                    // first working period, but we'll use the week days of all the periods.
                    this.startTime = workingPeriods[0].StartTime;
                    this.endTime   = workingPeriods[0].EndTime;

                    foreach (WorkingPeriod workingPeriod in workingPeriods)
                    {
                        foreach (DayOfTheWeek dayOfWeek in workingPeriods[0].DaysOfWeek)
                        {
                            if (!this.daysOfTheWeek.Contains(dayOfWeek))
                            {
                                this.daysOfTheWeek.Add(dayOfWeek);
                            }
                        }
                    }

                    break;

                default:
                    break;
                }
            }
        }