/// <summary>
        /// Writes the elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Mailbox);
            writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.Address, this.SmtpAddress);
            writer.WriteEndElement(); // Mailbox

            this.OofSettings.WriteToXml(writer, XmlElementNames.UserOofSettings);
        }
Пример #2
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Manifest);

            writer.WriteBase64ElementValue(manifestStream);
            
            writer.WriteEndElement();
        }
Пример #3
0
 /// <summary>
 /// Writes the elements to XML.
 /// </summary>
 /// <param name="writer">The writer.</param>
 internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
 {
     foreach (byte[] item in this.content)
     {
         writer.WriteStartElement(XmlNamespace.Types, ByteArrayArray.ItemXmlElementName);
         writer.WriteBase64ElementValue(item);
         writer.WriteEndElement();
     }
 }
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="requestedServerVersion">The requested server version.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer, ExchangeVersion requestedServerVersion)
        {
            if (string.IsNullOrEmpty(this.id))
            {
                throw new ArgumentException(Strings.IdPropertyMustBeSet);
            }

            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.OpenAsAdminOrSystemService);
            writer.WriteAttributeString(XmlElementNames.LogonType, this.logonType.ToString());
            if (requestedServerVersion >= ExchangeVersion.Exchange2013 && this.budgetType.HasValue)
            {
                writer.WriteAttributeString(XmlElementNames.BudgetType, ((int)this.budgetType.Value).ToString());
            }

            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ConnectingSID);
            writer.WriteElementValue(XmlNamespace.Types, this.idType.ToString(), this.id);
            writer.WriteEndElement(); // ConnectingSID
            writer.WriteEndElement(); // OpenAsAdminOrSystemService
        }
        /// <summary>
        /// Writes XML elements for GetPeopleInsights request
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.EmailAddresses);

            foreach (string emailAddress in this.Emailaddresses)
            {
                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.String, emailAddress);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer)
        {
            if (string.IsNullOrEmpty(this.id))
            {
                throw new ArgumentException(Strings.IdPropertyMustBeSet);
            }

            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ExchangeImpersonation);
            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ConnectingSID);

            // For 2007 SP1, use PrimarySmtpAddress for type SmtpAddress
            string connectingIdTypeLocalName =
                (this.idType == ConnectingIdType.SmtpAddress) && (writer.Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1) 
                    ? XmlElementNames.PrimarySmtpAddress 
                    : this.IdType.ToString();

            writer.WriteElementValue(
                XmlNamespace.Types,
                connectingIdTypeLocalName,
                this.id);

            writer.WriteEndElement(); // ConnectingSID
            writer.WriteEndElement(); // ExchangeImpersonation
        }
Пример #7
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (this.Ids != null)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Ids);

                foreach (string id in this.ids)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.Id,
                        id);
                }

                writer.WriteEndElement(); // Ids
            }
        }
Пример #8
0
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="ewsNamesapce">The ews namesapce.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void WriteToXml(
            EwsServiceXmlWriter writer,
            XmlNamespace ewsNamesapce,
            string xmlElementName)
        {
            if (this.Count > 0)
            {
                writer.WriteStartElement(ewsNamesapce, xmlElementName);

                foreach (AbstractFolderIdWrapper folderIdWrapper in this.ids)
                {
                    folderIdWrapper.WriteToXml(writer);
                }

                writer.WriteEndElement();
            }
        }
Пример #9
0
        /// <summary>
        /// Writes elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.To);

            if (this.targetPeriod != null)
            {
                writer.WriteAttributeValue(XmlAttributeNames.Kind, PeriodTarget);
                writer.WriteValue(this.targetPeriod.Id, XmlElementNames.To);
            }
            else
            {
                writer.WriteAttributeValue(XmlAttributeNames.Kind, GroupTarget);
                writer.WriteValue(this.targetGroup.Id, XmlElementNames.To);
            }

            writer.WriteEndElement(); // To
        }
        /// <summary>
        /// Generate XML to delete individual members.
        /// </summary>
        /// <param name="writer">Xml writer.</param>
        /// <param name="members">Members to delete.</param>
        private void WriteDeleteMembersToXml(EwsServiceXmlWriter writer, List <GroupMember> members)
        {
            if (members.Count != 0)
            {
                GroupMemberPropertyDefinition memberPropDef = new GroupMemberPropertyDefinition();

                foreach (GroupMember member in members)
                {
                    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.DeleteItemField);

                    memberPropDef.Key = member.Key;
                    memberPropDef.WriteToXml(writer);

                    writer.WriteEndElement();   // DeleteItemField
                }
            }
        }
        /// <summary>
        /// Writes the property value to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="propertyBag">The property bag.</param>
        /// <param name="isUpdateOperation">Indicates whether the context is an update operation.</param>
        internal override void WritePropertyValueToXml(
            EwsServiceXmlWriter writer,
            PropertyBag propertyBag,
            bool isUpdateOperation)
        {
            object value = propertyBag[this];

            if (value != null)
            {
                writer.WriteStartElement(XmlNamespace.Types, this.XmlElementName);

                DateTime convertedDateTime = GetConvertedDateTime(writer.Service, propertyBag, isUpdateOperation, value);

                writer.WriteValue(EwsUtilities.DateTimeToXSDateTime(convertedDateTime), this.Name);

                writer.WriteEndElement();
            }
        }
        /// <summary>
        /// Writes the elements to XML writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SubscriptionIds);

            foreach (string id in this.subscriptionIds)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.SubscriptionId,
                    id);
            }

            writer.WriteEndElement();

            writer.WriteElementValue(
                XmlNamespace.Messages,
                XmlElementNames.ConnectionTimeout,
                this.connectionTimeout);
        }
Пример #13
0
        /// <summary>
        /// Writes the bag's properties to XML.
        /// </summary>
        /// <param name="writer">The writer to write the properties to.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Types, this.Owner.GetXmlElementName());

            foreach (PropertyDefinition propertyDefinition in this.Owner.Schema)
            {
                // The following test should not be necessary since the property bag prevents
                // properties to be set if they don't have the CanSet flag, but it doesn't hurt...
                if (propertyDefinition.HasFlag(PropertyDefinitionFlags.CanSet, writer.Service.RequestedServerVersion))
                {
                    if (this.Contains(propertyDefinition))
                    {
                        propertyDefinition.WritePropertyValueToXml(writer, this, false /* isUpdateOperation */);
                    }
                }
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void WriteToXml(
            EwsServiceXmlWriter writer,
            XmlNamespace xmlNamespace,
            string xmlElementName)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteToXml",
                "writer is null");
            EwsUtilities.Assert(
                xmlElementName != null,
                "UserConfiguration.WriteToXml",
                "xmlElementName is null");

            writer.WriteStartElement(xmlNamespace, xmlElementName);

            // Write the UserConfigurationName element
            WriteUserConfigurationNameToXml(
                writer,
                XmlNamespace.Types,
                this.name,
                this.parentFolderId);

            // Write the Dictionary element
            if (this.IsPropertyUpdated(UserConfigurationProperties.Dictionary))
            {
                this.dictionary.WriteToXml(writer, XmlElementNames.Dictionary);
            }

            // Write the XmlData element
            if (this.IsPropertyUpdated(UserConfigurationProperties.XmlData))
            {
                this.WriteXmlDataToXml(writer);
            }

            // Write the BinaryData element
            if (this.IsPropertyUpdated(UserConfigurationProperties.BinaryData))
            {
                this.WriteBinaryDataToXml(writer);
            }

            writer.WriteEndElement();
        }
Пример #15
0
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer, string xmlElementName)
        {
            writer.WriteStartElement(XmlNamespace.Types, xmlElementName);

            if (this.Culture != null)
            {
                writer.WriteAttributeValue(
                    "xml",
                    "lang",
                    this.Culture);
            }

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.Message,
                this.Message);

            writer.WriteEndElement(); // xmlElementName
        }
        /// <summary>
        /// Writes the elements to XML writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SubscriptionIds);

            foreach (string id in this.subscriptionIds)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.SubscriptionId,
                    id);
            }

            writer.WriteEndElement();

            writer.WriteElementValue(
                XmlNamespace.Messages,
                XmlElementNames.ConnectionTimeout,
                this.connectionTimeout);
        }
Пример #17
0
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        private static void WriteToXml(
            EwsServiceXmlWriter writer,
            string xmlElementName,
            object startTime,
            object endTime)
        {
            writer.WriteStartElement(XmlNamespace.Types, xmlElementName);

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.StartTime,
                startTime);

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.EndTime,
                endTime);

            writer.WriteEndElement(); // xmlElementName
        }
Пример #18
0
        /// <summary>
        /// Writes the update to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="ewsObject">The ews object.</param>
        /// <param name="propertyDefinition">Property definition.</param>
        /// <returns>True if property generated serialization.</returns>
        bool ICustomUpdateSerializer.WriteSetUpdateToXml(
            EwsServiceXmlWriter writer,
            ServiceObject ewsObject,
            PropertyDefinition propertyDefinition)
        {
            // If the collection is empty, delete the property.
            if (this.Count == 0)
            {
                writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetDeleteFieldXmlElementName());
                propertyDefinition.WriteToXml(writer);
                writer.WriteEndElement();
                return(true);
            }

            // Otherwise, use the default XML serializer.
            else
            {
                return(false);
            }
        }
Пример #19
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Manifest);

            writer.WriteBase64ElementValue(manifestStream);

            if (!string.IsNullOrEmpty(this.marketplaceAssetId))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.MarketplaceAssetId, this.marketplaceAssetId);

                if (!string.IsNullOrEmpty(this.marketplaceContentMarket))
                {
                    writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.MarketplaceContentMarket, this.marketplaceContentMarket);
                }

                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.SendWelcomeEmail, this.sendWelcomeEmail);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (!string.IsNullOrEmpty(this.mailboxSmtpAddress))
            {
                writer.WriteElementValue(
                    XmlNamespace.Messages,
                    XmlElementNames.MailboxSmtpAddress,
                    this.mailboxSmtpAddress);
            }

            writer.WriteElementValue(
                XmlNamespace.Messages,
                XmlElementNames.RemoveOutlookRuleBlob,
                this.RemoveOutlookRuleBlob);
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Operations);
            foreach (RuleOperation operation in this.inboxRuleOperations)
            {
                operation.WriteToXml(writer, operation.XmlElementName);
            }
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            base.WriteElementsToXml(writer);

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

            foreach (DelegateUser delegateUser in this.DelegateUsers)
            {
                delegateUser.WriteToXml(writer, XmlElementNames.DelegateUser);
            }

            writer.WriteEndElement(); // DelegateUsers

            if (this.MeetingRequestsDeliveryScope.HasValue)
            {
                writer.WriteElementValue(
                    XmlNamespace.Messages,
                    XmlElementNames.DeliverMeetingRequests,
                    this.MeetingRequestsDeliveryScope.Value);
            }
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            this.PropertySet.WriteToXml(writer, ServiceObjectType.Item);

            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SyncFolderId);
            this.SyncFolderId.WriteToXml(writer);
            writer.WriteEndElement();

            writer.WriteElementValue(
                XmlNamespace.Messages,
                XmlElementNames.SyncState,
                this.SyncState);

            this.IgnoredItemIds.WriteToXml(
                writer,
                XmlNamespace.Messages,
                XmlElementNames.Ignore);

            writer.WriteElementValue(
                XmlNamespace.Messages,
                XmlElementNames.MaxChangesReturned,
                this.MaxChangesReturned);

            if (this.Service.RequestedServerVersion >= ExchangeVersion.Exchange2010)
            {
                writer.WriteElementValue(
                    XmlNamespace.Messages,
                    XmlElementNames.SyncScope,
                    this.syncScope);
            }

            if (this.NumberOfDays != 0)
            {
                writer.WriteElementValue(
                    XmlNamespace.Messages,
                    XmlElementNames.NumberOfDays,
                    this.numberOfDays);
            }
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Manifest);

            writer.WriteBase64ElementValue(manifestStream);

            writer.WriteEndElement();

            if (!string.IsNullOrEmpty(this.marketplaceAssetId))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.MarketplaceAssetId, this.marketplaceAssetId);

                if (!string.IsNullOrEmpty(this.marketplaceContentMarket))
                {
                    writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.MarketplaceContentMarket, this.marketplaceContentMarket);
                }

                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.SendWelcomeEmail, this.sendWelcomeEmail);
            }

            writer.WriteEndElement();
        }
        /// <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);
        }
        /// <summary>
        /// Writes a byte array to Xml.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="byteArray">Byte array to write.</param>
        /// <param name="xmlElementName">Name of the Xml element.</param>
        private static void WriteByteArrayToXml(
            EwsServiceXmlWriter writer,
            byte[] byteArray,
            string xmlElementName)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteByteArrayToXml",
                "writer is null");
            EwsUtilities.Assert(
                xmlElementName != null,
                "UserConfiguration.WriteByteArrayToXml",
                "xmlElementName is null");

            writer.WriteStartElement(XmlNamespace.Types, xmlElementName);

            if (byteArray != null && byteArray.Length > 0)
            {
                writer.WriteValue(Convert.ToBase64String(byteArray), xmlElementName);
            }

            writer.WriteEndElement();
        }
Пример #26
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>
        /// Writes elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfigurationDictionary.WriteElementsToXml",
                "writer is null");

            foreach (KeyValuePair <object, object> dictionaryEntry in this.dictionary)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.DictionaryEntry);

                this.WriteObjectToXml(
                    writer,
                    XmlElementNames.DictionaryKey,
                    dictionaryEntry.Key);

                this.WriteObjectToXml(
                    writer,
                    XmlElementNames.DictionaryValue,
                    dictionaryEntry.Value);

                writer.WriteEndElement();
            }
        }
Пример #28
0
        /// <summary>
        /// Writes elements and content to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            base.WriteElementsToXml(writer);

            if (writer.Service.RequestedServerVersion > ExchangeVersion.Exchange2007_SP1)
            {
                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.IsContactPhoto, this.isContactPhoto);
            }

            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Content);

            if (!string.IsNullOrEmpty(this.FileName))
            {
                using (FileStream fileStream = new FileStream(this.FileName, FileMode.Open, FileAccess.Read))
                {
                    writer.WriteBase64ElementValue(fileStream);
                }
            }
            else if (this.ContentStream != null)
            {
                writer.WriteBase64ElementValue(this.ContentStream);
            }
            else if (this.Content != null)
            {
                writer.WriteBase64ElementValue(this.Content);
            }
            else
            {
                EwsUtilities.Assert(
                    false,
                    "FileAttachment.WriteElementsToXml",
                    "The attachment's content is not set.");
            }

            writer.WriteEndElement();
        }
Пример #29
0
 /// <summary>
 /// WriteToXml
 /// </summary>
 /// <param name="writer"></param>
 internal void WriteToXml(EwsServiceXmlWriter writer)
 {
     writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ManagementRole);
     WriteRolesToXml(writer, this.userRoles, XmlElementNames.UserRoles);
     WriteRolesToXml(writer, this.applicationRoles, XmlElementNames.ApplicationRoles);
     writer.WriteEndElement();
 }
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void WriteToXml(
            EwsServiceXmlWriter writer,
            XmlNamespace xmlNamespace,
            string xmlElementName)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteToXml",
                "writer is null");
            EwsUtilities.Assert(
                xmlElementName != null,
                "UserConfiguration.WriteToXml",
                "xmlElementName is null");

            writer.WriteStartElement(xmlNamespace, xmlElementName);

            // Write the UserConfigurationName element
            WriteUserConfigurationNameToXml(
                writer, 
                XmlNamespace.Types, 
                this.name, 
                this.parentFolderId);

            // Write the Dictionary element
            if (this.IsPropertyUpdated(UserConfigurationProperties.Dictionary))
            {
                this.dictionary.WriteToXml(writer, XmlElementNames.Dictionary);
            }

            // Write the XmlData element
            if (this.IsPropertyUpdated(UserConfigurationProperties.XmlData))
            {
                this.WriteXmlDataToXml(writer);
            }

            // Write the BinaryData element
            if (this.IsPropertyUpdated(UserConfigurationProperties.BinaryData))
            {
                this.WriteBinaryDataToXml(writer);
            }

            writer.WriteEndElement();
        }
Пример #31
0
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="request">The request being emitted.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer, GetUserAvailabilityRequest request)
        {
            if (request.IsFreeBusyViewRequested)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.FreeBusyViewOptions);

                request.TimeWindow.WriteToXmlUnscopedDatesOnly(writer, XmlElementNames.TimeWindow);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MergedFreeBusyIntervalInMinutes,
                    this.MergedFreeBusyInterval);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.RequestedView,
                    this.RequestedFreeBusyView);

                writer.WriteEndElement(); // FreeBusyViewOptions
            }

            if (request.IsSuggestionsViewRequested)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.SuggestionsViewOptions);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.GoodThreshold,
                    this.GoodSuggestionThreshold);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MaximumResultsByDay,
                    this.MaximumSuggestionsPerDay);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MaximumNonWorkHourResultsByDay,
                    this.MaximumNonWorkHoursSuggestionsPerDay);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MeetingDurationInMinutes,
                    this.MeetingDuration);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MinimumSuggestionQuality,
                    this.MinimumSuggestionQuality);

                TimeWindow timeWindowToSerialize = this.DetailedSuggestionsWindow == null ?
                                                   request.TimeWindow :
                                                   this.DetailedSuggestionsWindow;

                timeWindowToSerialize.WriteToXmlUnscopedDatesOnly(writer, XmlElementNames.DetailedSuggestionsWindow);

                if (this.CurrentMeetingTime.HasValue)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.CurrentMeetingTime,
                        this.CurrentMeetingTime.Value);
                }

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.GlobalObjectId,
                    this.GlobalObjectId);

                writer.WriteEndElement(); // SuggestionsViewOptions
            }
        }
Пример #32
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (this.SearchFilter != null)
            {
                // Emit the Restriction element
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Restriction);
                this.SearchFilter.WriteToXml(writer);
                writer.WriteEndElement();
            }

            // Emit the View element
            this.View.WriteToXml(writer, null);

            // Emit the SortOrder
            this.View.WriteOrderByToXml(writer);

            // Emit the ParentFolderId element
            if (this.FolderId != null)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.ParentFolderId);
                this.FolderId.WriteToXml(writer);
                writer.WriteEndElement();
            }

            if (!string.IsNullOrEmpty(this.QueryString))
            {
                // Emit the QueryString element
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.QueryString);
                writer.WriteValue(this.QueryString, XmlElementNames.QueryString);
                writer.WriteEndElement();
            }

            // Emit the SuggestionIndex-enabled elements
            if (this.SearchPeopleSuggestionIndex)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchPeopleSuggestionIndex);
                writer.WriteValue(this.SearchPeopleSuggestionIndex.ToString().ToLowerInvariant(), XmlElementNames.SearchPeopleSuggestionIndex);
                writer.WriteEndElement();

                // Write the Context key value pairs
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchPeopleContext);
                foreach (KeyValuePair<string, string> contextItem in this.Context)
                {
                    writer.WriteStartElement(XmlNamespace.Messages, "ContextProperty");

                    writer.WriteStartElement(XmlNamespace.Messages, "Key");
                    writer.WriteValue(contextItem.Key, "Key");
                    writer.WriteEndElement();

                    writer.WriteStartElement(XmlNamespace.Messages, "Value");
                    writer.WriteValue(contextItem.Value, "Value");
                    writer.WriteEndElement();

                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // Write the Query Mode Sources
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchPeopleQuerySources);
                foreach (string querySource in this.QueryMode.Sources)
                {
                    writer.WriteStartElement(XmlNamespace.Messages, "Source");
                    writer.WriteValue(querySource, "Source");
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }

            if (this.Service.RequestedServerVersion >= this.GetMinimumRequiredServerVersion())
            {
                if (this.View.PropertySet != null)
                {
                    this.View.PropertySet.WriteToXml(writer, ServiceObjectType.Persona);
                }
            }
        }
Пример #33
0
        /// <summary>
        /// Writes elements and content to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            base.WriteElementsToXml(writer);

            if (writer.Service.RequestedServerVersion > ExchangeVersion.Exchange2007_SP1)
            {
                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.IsContactPhoto, this.isContactPhoto);
            }

            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Content);

            if (!string.IsNullOrEmpty(this.FileName))
            {
                using (FileStream fileStream = new FileStream(this.FileName, FileMode.Open, FileAccess.Read))
                {
                    writer.WriteBase64ElementValue(fileStream);
                }
            }
            else if (this.ContentStream != null)
            {
                writer.WriteBase64ElementValue(this.ContentStream);
            }
            else if (this.Content != null)
            {
                writer.WriteBase64ElementValue(this.Content);
            }
            else
            {
                EwsUtilities.Assert(
                    false,
                    "FileAttachment.WriteElementsToXml",
                    "The attachment's content is not set.");
            }

            writer.WriteEndElement();
        }
Пример #34
0
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.MailboxData);

            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Email);
            writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.Address, this.SmtpAddress);
            writer.WriteEndElement(); // Email

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.AttendeeType,
                this.attendeeType);

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.ExcludeConflicts,
                this.excludeConflicts);

            writer.WriteEndElement(); // MailboxData
        }
        /// <summary>
        /// Writes elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (this.AssignCategories.Count > 0)
            {
                this.AssignCategories.WriteToXml(writer, XmlElementNames.AssignCategories);
            }

            if (this.CopyToFolder != null)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.CopyToFolder);
                this.CopyToFolder.WriteToXml(writer);
                writer.WriteEndElement();
            }

            if (this.Delete != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types, 
                    XmlElementNames.Delete, 
                    this.Delete);
            }

            if (this.ForwardAsAttachmentToRecipients.Count > 0)
            {
                this.ForwardAsAttachmentToRecipients.WriteToXml(writer, XmlElementNames.ForwardAsAttachmentToRecipients);
            }

            if (this.ForwardToRecipients.Count > 0)
            {
                this.ForwardToRecipients.WriteToXml(writer, XmlElementNames.ForwardToRecipients);
            }

            if (this.MarkImportance.HasValue)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types, 
                    XmlElementNames.MarkImportance, 
                    this.MarkImportance.Value);
            }

            if (this.MarkAsRead != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MarkAsRead,
                    this.MarkAsRead);
            }

            if (this.MoveToFolder != null)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.MoveToFolder);
                this.MoveToFolder.WriteToXml(writer);
                writer.WriteEndElement();
            }

            if (this.PermanentDelete != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types, 
                    XmlElementNames.PermanentDelete, 
                    this.PermanentDelete);
            }

            if (this.RedirectToRecipients.Count > 0)
            {
                this.RedirectToRecipients.WriteToXml(writer, XmlElementNames.RedirectToRecipients);
            }

            if (this.SendSMSAlertToRecipients.Count > 0)
            {
                EmailAddressCollection emailCollection = ConvertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection(this.SendSMSAlertToRecipients);
                emailCollection.WriteToXml(writer, XmlElementNames.SendSMSAlertToRecipients);
            }

            if (this.ServerReplyWithMessage != null)
            {
                this.ServerReplyWithMessage.WriteToXml(writer, XmlElementNames.ServerReplyWithMessage);
            }

            if (this.StopProcessingRules != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types, 
                    XmlElementNames.StopProcessingRules, 
                    this.StopProcessingRules);
            }
        }
 /// <summary>
 /// Writes a dictionary entry type to Xml.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="dictionaryObjectType">Type to write.</param>
 private void WriteEntryTypeToXml(EwsServiceXmlWriter writer, UserConfigurationDictionaryObjectType dictionaryObjectType)
 {
     writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Type);
     writer.WriteValue(dictionaryObjectType.ToString(), XmlElementNames.Type);
     writer.WriteEndElement();
 }
Пример #37
0
 /// <summary>
 /// Writes an empty OofReply to XML.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="xmlElementName">Name of the XML element.</param>
 internal static void WriteEmptyReplyToXml(EwsServiceXmlWriter writer, string xmlElementName)
 {
     writer.WriteStartElement(XmlNamespace.Types, xmlElementName);
     writer.WriteEndElement(); // xmlElementName
 }
Пример #38
0
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer, string xmlElementName)
        {
            writer.WriteStartElement(XmlNamespace.Types, xmlElementName);

            if (this.Culture != null)
            {
                writer.WriteAttributeValue(
                    "xml",
                    "lang",
                    this.Culture);
            }

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.Message,
                this.Message);

            writer.WriteEndElement(); // xmlElementName
        }
        /// <summary>
        /// Writes a byte array to Xml.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="byteArray">Byte array to write.</param>
        /// <param name="xmlElementName">Name of the Xml element.</param>
        private static void WriteByteArrayToXml(
            EwsServiceXmlWriter writer,
            byte[] byteArray,
            string xmlElementName)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteByteArrayToXml",
                "writer is null");
            EwsUtilities.Assert(
                xmlElementName != null,
                "UserConfiguration.WriteByteArrayToXml",
                "xmlElementName is null");

            writer.WriteStartElement(XmlNamespace.Types, xmlElementName);

            if (byteArray != null && byteArray.Length > 0)
            {
                writer.WriteValue(Convert.ToBase64String(byteArray), xmlElementName);
            }

            writer.WriteEndElement();
        }
Пример #40
0
 /// <summary>
 /// Writes XML elements.
 /// </summary>
 /// <param name="writer">The writer.</param>
 internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
 {
     writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Mailbox);
     writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.Address, this.SmtpAddress);
     writer.WriteEndElement(); // Mailbox
 }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchQueries);
            foreach (MailboxQuery mailboxQuery in this.SearchQueries)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.MailboxQuery);
                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.Query, mailboxQuery.Query);
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes);
                foreach (MailboxSearchScope mailboxSearchScope in mailboxQuery.MailboxSearchScopes)
                {
                    // The checks here silently downgrade the schema based on compatability checks, to recieve errors use the validate method
                    if (mailboxSearchScope.SearchScopeType == MailboxSearchScopeType.LegacyExchangeDN || DiscoverySchemaChanges.SearchMailboxesAdditionalSearchScopes.IsCompatible(this))
                    {
                        writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScope);
                        writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.Mailbox, mailboxSearchScope.Mailbox);
                        writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.SearchScope, mailboxSearchScope.SearchScope);

                        if (DiscoverySchemaChanges.SearchMailboxesExtendedData.IsCompatible(this))
                        {
                            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ExtendedAttributes);

                            if (mailboxSearchScope.SearchScopeType != MailboxSearchScopeType.LegacyExchangeDN)
                            {
                                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ExtendedAttribute);
                                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.ExtendedAttributeName, XmlElementNames.SearchScopeType);
                                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.ExtendedAttributeValue, mailboxSearchScope.SearchScopeType);
                                writer.WriteEndElement();
                            }

                            if (mailboxSearchScope.ExtendedAttributes != null && mailboxSearchScope.ExtendedAttributes.Count > 0)
                            {
                                foreach (ExtendedAttribute attribute in mailboxSearchScope.ExtendedAttributes)
                                {
                                    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ExtendedAttribute);
                                    writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.ExtendedAttributeName, attribute.Name);
                                    writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.ExtendedAttributeValue, attribute.Value);
                                    writer.WriteEndElement();
                                }
                            }

                            writer.WriteEndElement();  // ExtendedData
                        }

                        writer.WriteEndElement();   // MailboxSearchScope
                    }
                }

                writer.WriteEndElement();   // MailboxSearchScopes
                writer.WriteEndElement();   // MailboxQuery
            }

            writer.WriteEndElement();   // SearchQueries
            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.ResultType, this.ResultType);

            if (this.PreviewItemResponseShape != null)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.PreviewItemResponseShape);
                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.BaseShape, this.PreviewItemResponseShape.BaseShape);
                if (this.PreviewItemResponseShape.AdditionalProperties != null && this.PreviewItemResponseShape.AdditionalProperties.Length > 0)
                {
                    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.AdditionalProperties);
                    foreach (ExtendedPropertyDefinition additionalProperty in this.PreviewItemResponseShape.AdditionalProperties)
                    {
                        additionalProperty.WriteToXml(writer);
                    }

                    writer.WriteEndElement();   // AdditionalProperties
                }

                writer.WriteEndElement();   // PreviewItemResponseShape
            }

            if (!string.IsNullOrEmpty(this.SortByProperty))
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SortBy);
                writer.WriteAttributeValue(XmlElementNames.Order, this.SortOrder.ToString());
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.FieldURI);
                writer.WriteAttributeValue(XmlElementNames.FieldURI, this.sortByProperty);
                writer.WriteEndElement();   // FieldURI
                writer.WriteEndElement();   // SortBy
            }

            // Language
            if (!string.IsNullOrEmpty(this.Language))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.Language, this.Language);
            }

            // Dedupe
            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.Deduplication, this.performDeduplication);

            if (this.PageSize > 0)
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.PageSize, this.PageSize.ToString());
            }

            if (!string.IsNullOrEmpty(this.PageItemReference))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.PageItemReference, this.PageItemReference);
            }

            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.PageDirection, this.PageDirection.ToString());
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.ActionType, this.ActionType.ToString());
            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.HoldId, this.HoldId);
            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.Query, this.Query ?? string.Empty);
            if (this.Mailboxes != null && this.Mailboxes.Length > 0)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Mailboxes);
                foreach (string mailbox in this.Mailboxes)
                {
                    writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.String, mailbox);
                }

                writer.WriteEndElement();   // Mailboxes
            }

            // Language
            if (!string.IsNullOrEmpty(this.Language))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.Language, this.Language);
            }

            if (!string.IsNullOrEmpty(this.InPlaceHoldIdentity))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.InPlaceHoldIdentity, this.InPlaceHoldIdentity);
            }

            if (!string.IsNullOrEmpty(this.ItemHoldPeriod))
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.ItemHoldPeriod, this.ItemHoldPeriod);
            }
        }
Пример #43
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (this.SearchFilter != null)
            {
                // Emit the Restriction element
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Restriction);
                this.SearchFilter.WriteToXml(writer);
                writer.WriteEndElement();
            }

            // Emit the View element
            this.View.WriteToXml(writer, null);

            // Emit the SortOrder
            this.View.WriteOrderByToXml(writer);

            // Emit the ParentFolderId element
            if (this.FolderId != null)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.ParentFolderId);
                this.FolderId.WriteToXml(writer);
                writer.WriteEndElement();
            }

            if (!string.IsNullOrEmpty(this.QueryString))
            {
                // Emit the QueryString element
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.QueryString);
                writer.WriteValue(this.QueryString, XmlElementNames.QueryString);
                writer.WriteEndElement();
            }

            // Emit the SuggestionIndex-enabled elements
            if (this.SearchPeopleSuggestionIndex)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchPeopleSuggestionIndex);
                writer.WriteValue(this.SearchPeopleSuggestionIndex.ToString().ToLowerInvariant(), XmlElementNames.SearchPeopleSuggestionIndex);
                writer.WriteEndElement();

                // Write the Context key value pairs
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchPeopleContext);
                foreach (KeyValuePair <string, string> contextItem in this.Context)
                {
                    writer.WriteStartElement(XmlNamespace.Types, "ContextProperty");

                    writer.WriteStartElement(XmlNamespace.Types, "Key");
                    writer.WriteValue(contextItem.Key, "Key");
                    writer.WriteEndElement();

                    writer.WriteStartElement(XmlNamespace.Types, "Value");
                    writer.WriteValue(contextItem.Value, "Value");
                    writer.WriteEndElement();

                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // Write the Query Mode Sources
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SearchPeopleQuerySources);
                foreach (string querySource in this.QueryMode.Sources)
                {
                    writer.WriteStartElement(XmlNamespace.Types, "Source");
                    writer.WriteValue(querySource, "Source");
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }

            if (this.Service.RequestedServerVersion >= this.GetMinimumRequiredServerVersion())
            {
                if (this.View.PropertySet != null)
                {
                    this.View.PropertySet.WriteToXml(writer, ServiceObjectType.Persona);
                }
            }
        }
Пример #44
0
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(
                XmlNamespace.Types,
                XmlElementNames.ConversationAction);
            try
            {
                string actionValue = String.Empty;
                switch (this.Action)
                {
                case ConversationActionType.AlwaysCategorize:
                    actionValue = XmlElementNames.AlwaysCategorize;
                    break;

                case ConversationActionType.AlwaysDelete:
                    actionValue = XmlElementNames.AlwaysDelete;
                    break;

                case ConversationActionType.AlwaysMove:
                    actionValue = XmlElementNames.AlwaysMove;
                    break;

                case ConversationActionType.Delete:
                    actionValue = XmlElementNames.Delete;
                    break;

                case ConversationActionType.Copy:
                    actionValue = XmlElementNames.Copy;
                    break;

                case ConversationActionType.Move:
                    actionValue = XmlElementNames.Move;
                    break;

                case ConversationActionType.SetReadState:
                    actionValue = XmlElementNames.SetReadState;
                    break;

                case ConversationActionType.SetRetentionPolicy:
                    actionValue = XmlElementNames.SetRetentionPolicy;
                    break;

                case ConversationActionType.Flag:
                    actionValue = XmlElementNames.Flag;
                    break;

                default:
                    throw new ArgumentException("ConversationAction");
                }

                // Emit the action element
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.Action,
                    actionValue);

                // Emit the conversation id element
                this.ConversationId.WriteToXml(
                    writer,
                    XmlNamespace.Types,
                    XmlElementNames.ConversationId);

                if (this.Action == ConversationActionType.AlwaysCategorize ||
                    this.Action == ConversationActionType.AlwaysDelete ||
                    this.Action == ConversationActionType.AlwaysMove)
                {
                    // Emit the ProcessRightAway element
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.ProcessRightAway,
                        EwsUtilities.BoolToXSBool(this.ProcessRightAway));
                }

                if (this.Action == ConversationActionType.AlwaysCategorize)
                {
                    // Emit the categories element
                    if (this.Categories != null && this.Categories.Count > 0)
                    {
                        this.Categories.WriteToXml(
                            writer,
                            XmlNamespace.Types,
                            XmlElementNames.Categories);
                    }
                }
                else if (this.Action == ConversationActionType.AlwaysDelete)
                {
                    // Emit the EnableAlwaysDelete element
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.EnableAlwaysDelete,
                        EwsUtilities.BoolToXSBool(this.EnableAlwaysDelete));
                }
                else if (this.Action == ConversationActionType.AlwaysMove)
                {
                    // Emit the Move Folder Id
                    if (this.DestinationFolderId != null)
                    {
                        writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.DestinationFolderId);
                        this.DestinationFolderId.WriteToXml(writer);
                        writer.WriteEndElement();
                    }
                }
                else
                {
                    if (this.ContextFolderId != null)
                    {
                        writer.WriteStartElement(
                            XmlNamespace.Types,
                            XmlElementNames.ContextFolderId);

                        this.ContextFolderId.WriteToXml(writer);

                        writer.WriteEndElement();
                    }

                    if (this.ConversationLastSyncTime.HasValue)
                    {
                        writer.WriteElementValue(
                            XmlNamespace.Types,
                            XmlElementNames.ConversationLastSyncTime,
                            this.ConversationLastSyncTime.Value);
                    }

                    if (this.Action == ConversationActionType.Copy)
                    {
                        EwsUtilities.Assert(
                            this.DestinationFolderId != null,
                            "ApplyconversationActionRequest",
                            "DestinationFolderId should be set when performing copy action");

                        writer.WriteStartElement(
                            XmlNamespace.Types,
                            XmlElementNames.DestinationFolderId);
                        this.DestinationFolderId.WriteToXml(writer);
                        writer.WriteEndElement();
                    }
                    else if (this.Action == ConversationActionType.Move)
                    {
                        EwsUtilities.Assert(
                            this.DestinationFolderId != null,
                            "ApplyconversationActionRequest",
                            "DestinationFolderId should be set when performing move action");

                        writer.WriteStartElement(
                            XmlNamespace.Types,
                            XmlElementNames.DestinationFolderId);
                        this.DestinationFolderId.WriteToXml(writer);
                        writer.WriteEndElement();
                    }
                    else if (this.Action == ConversationActionType.Delete)
                    {
                        EwsUtilities.Assert(
                            this.DeleteType.HasValue,
                            "ApplyconversationActionRequest",
                            "DeleteType should be specified when deleting a conversation.");

                        writer.WriteElementValue(
                            XmlNamespace.Types,
                            XmlElementNames.DeleteType,
                            this.DeleteType.Value);
                    }
                    else if (this.Action == ConversationActionType.SetReadState)
                    {
                        EwsUtilities.Assert(
                            this.IsRead.HasValue,
                            "ApplyconversationActionRequest",
                            "IsRead should be specified when marking/unmarking a conversation as read.");

                        writer.WriteElementValue(
                            XmlNamespace.Types,
                            XmlElementNames.IsRead,
                            this.IsRead.Value);

                        if (this.SuppressReadReceipts.HasValue)
                        {
                            writer.WriteElementValue(
                                XmlNamespace.Types,
                                XmlElementNames.SuppressReadReceipts,
                                this.SuppressReadReceipts.Value);
                        }
                    }
                    else if (this.Action == ConversationActionType.SetRetentionPolicy)
                    {
                        EwsUtilities.Assert(
                            this.RetentionPolicyType.HasValue,
                            "ApplyconversationActionRequest",
                            "RetentionPolicyType should be specified when setting a retention policy on a conversation.");

                        writer.WriteElementValue(
                            XmlNamespace.Types,
                            XmlElementNames.RetentionPolicyType,
                            this.RetentionPolicyType.Value);

                        if (this.RetentionPolicyTagId.HasValue)
                        {
                            writer.WriteElementValue(
                                XmlNamespace.Types,
                                XmlElementNames.RetentionPolicyTagId,
                                this.RetentionPolicyTagId.Value);
                        }
                    }
                    else if (this.Action == ConversationActionType.Flag)
                    {
                        EwsUtilities.Assert(
                            this.Flag != null,
                            "ApplyconversationActionRequest",
                            "Flag should be specified when flagging conversation items.");

                        writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Flag);
                        this.Flag.WriteElementsToXml(writer);
                        writer.WriteEndElement();
                    }
                }
            }
            finally
            {
                writer.WriteEndElement();
            }
        }
Пример #45
0
        /// <summary>
        /// Writes the property set to XML.
        /// </summary>
        /// <param name="writer">The writer to write to.</param>
        /// <param name="serviceObjectType">The type of service object the property set is emitted for.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer, ServiceObjectType serviceObjectType)
        {
            string shapeElementName = GetShapeName(serviceObjectType);

            writer.WriteStartElement(XmlNamespace.Messages, shapeElementName);

            writer.WriteElementValue(
                XmlNamespace.Types,
                XmlElementNames.BaseShape,
                defaultPropertySetMap.Member[this.BasePropertySet]);

            if (serviceObjectType == ServiceObjectType.Item)
            {
                if (this.RequestedBodyType.HasValue)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.BodyType,
                        this.RequestedBodyType.Value);
                }

                if (this.RequestedUniqueBodyType.HasValue)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.UniqueBodyType,
                        this.RequestedUniqueBodyType.Value);
                }

                if (this.RequestedNormalizedBodyType.HasValue)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.NormalizedBodyType,
                        this.RequestedNormalizedBodyType.Value);
                }

                if (this.FilterHtmlContent.HasValue)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.FilterHtmlContent,
                        this.FilterHtmlContent.Value);
                }

                if (this.ConvertHtmlCodePageToUTF8.HasValue &&
                    writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2010_SP1)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.ConvertHtmlCodePageToUTF8,
                        this.ConvertHtmlCodePageToUTF8.Value);
                }

                if (!string.IsNullOrEmpty(this.InlineImageUrlTemplate) &&
                    writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.InlineImageUrlTemplate,
                        this.InlineImageUrlTemplate);
                }

                if (this.BlockExternalImages.HasValue &&
                    writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.BlockExternalImages,
                        this.BlockExternalImages.Value);
                }

                if (this.AddBlankTargetToLinks.HasValue &&
                    writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.AddBlankTargetToLinks,
                        this.AddBlankTargetToLinks.Value);
                }

                if (this.MaximumBodySize.HasValue &&
                    writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.MaximumBodySize,
                        this.MaximumBodySize.Value);
                }
            }

            if (this.additionalProperties.Count > 0)
            {
                WriteAdditionalPropertiesToXml(writer, this.additionalProperties);
            }

            writer.WriteEndElement(); // Item/FolderShape
        }
Пример #46
0
 /// <summary>
 /// Writes the elements to XML.
 /// </summary>
 /// <param name="writer">The writer.</param>
 internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
 {
     writer.WriteStartElement(this.Namespace, XmlElementNames.Mailbox);
     base.WriteElementsToXml(writer);
     writer.WriteEndElement();
 }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Mailboxes);
            foreach (string mailbox in this.Mailboxes)
            {
                writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.LegacyDN, mailbox);
            }

            writer.WriteEndElement();

            writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.SearchArchiveOnly, this.SearchArchiveOnly);
        }
Пример #48
0
        /// <summary>
        /// Writes elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (this.AssignCategories.Count > 0)
            {
                this.AssignCategories.WriteToXml(writer, XmlElementNames.AssignCategories);
            }

            if (this.CopyToFolder != null)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.CopyToFolder);
                this.CopyToFolder.WriteToXml(writer);
                writer.WriteEndElement();
            }

            if (this.Delete != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.Delete,
                    this.Delete);
            }

            if (this.ForwardAsAttachmentToRecipients.Count > 0)
            {
                this.ForwardAsAttachmentToRecipients.WriteToXml(writer, XmlElementNames.ForwardAsAttachmentToRecipients);
            }

            if (this.ForwardToRecipients.Count > 0)
            {
                this.ForwardToRecipients.WriteToXml(writer, XmlElementNames.ForwardToRecipients);
            }

            if (this.MarkImportance.HasValue)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MarkImportance,
                    this.MarkImportance.Value);
            }

            if (this.MarkAsRead != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MarkAsRead,
                    this.MarkAsRead);
            }

            if (this.MoveToFolder != null)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.MoveToFolder);
                this.MoveToFolder.WriteToXml(writer);
                writer.WriteEndElement();
            }

            if (this.PermanentDelete != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.PermanentDelete,
                    this.PermanentDelete);
            }

            if (this.RedirectToRecipients.Count > 0)
            {
                this.RedirectToRecipients.WriteToXml(writer, XmlElementNames.RedirectToRecipients);
            }

            if (this.SendSMSAlertToRecipients.Count > 0)
            {
                EmailAddressCollection emailCollection = ConvertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection(this.SendSMSAlertToRecipients);
                emailCollection.WriteToXml(writer, XmlElementNames.SendSMSAlertToRecipients);
            }

            if (this.ServerReplyWithMessage != null)
            {
                this.ServerReplyWithMessage.WriteToXml(writer, XmlElementNames.ServerReplyWithMessage);
            }

            if (this.StopProcessingRules != false)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.StopProcessingRules,
                    this.StopProcessingRules);
            }
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            if (null != this.requestedExtensionIds && this.requestedExtensionIds.Count > 0)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.ClientExtensionRequestedIds);
                requestedExtensionIds.WriteElementsToXml(writer);
                writer.WriteEndElement();
            }
            
            if (this.isUserScope)
            {
                writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.ClientExtensionUserRequest);

                writer.WriteAttributeValue(XmlAttributeNames.ClientExtensionUserIdentity, this.userId);

                if (shouldReturnEnabledOnly)
                {
                    writer.WriteAttributeValue(XmlAttributeNames.ClientExtensionEnabledOnly, this.shouldReturnEnabledOnly);
                }

                if (null != this.userEnabledExtensionIds && this.userEnabledExtensionIds.Count > 0)
                {
                    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ClientExtensionUserEnabled);
                    userEnabledExtensionIds.WriteElementsToXml(writer);
                    writer.WriteEndElement();
                }

                if (null != this.userDisabledExtensionIds && this.userDisabledExtensionIds.Count > 0)
                {
                    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ClientExtensionUserDisabled);
                    userDisabledExtensionIds.WriteElementsToXml(writer);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }

            if (isDebug)
            {
                writer.WriteElementValue(XmlNamespace.Messages, XmlElementNames.ClientExtensionIsDebug, isDebug);
            }
        }
        /// <summary>
        /// Writes XML elements.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            // Emit the EmailAddress element
            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.Email);
            writer.WriteValue(this.EmailAddress, XmlElementNames.Email);
            writer.WriteEndElement();

            writer.WriteStartElement(XmlNamespace.Messages, XmlElementNames.SizeRequested);
            writer.WriteValue(this.UserPhotoSize, XmlElementNames.SizeRequested);
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes a dictionary object (key or value) to Xml.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlElementName">The Xml element name.</param>
        /// <param name="dictionaryObject">The object to write.</param>
        private void WriteObjectToXml(
            EwsServiceXmlWriter writer,
            string xmlElementName,
            object dictionaryObject)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfigurationDictionary.WriteObjectToXml",
                "writer is null");
            EwsUtilities.Assert(
                xmlElementName != null,
                "UserConfigurationDictionary.WriteObjectToXml",
                "xmlElementName is null");

            writer.WriteStartElement(XmlNamespace.Types, xmlElementName);

            if (dictionaryObject == null)
            {
                EwsUtilities.Assert(
                    xmlElementName != XmlElementNames.DictionaryKey,
                    "UserConfigurationDictionary.WriteObjectToXml",
                    "Key is null");

                writer.WriteAttributeValue(
                    EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix,
                    XmlAttributeNames.Nil,
                    EwsUtilities.XSTrue);
            }
            else
            {
                this.WriteObjectValueToXml(writer, dictionaryObject);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes to Xml.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="name">The user configuration name.</param>
        /// <param name="parentFolderId">The Id of the folder containing the user configuration.</param>
        internal static void WriteUserConfigurationNameToXml(
            EwsServiceXmlWriter writer,
            XmlNamespace xmlNamespace,
            string name,
            FolderId parentFolderId)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteUserConfigurationNameToXml",
                "writer is null");
            EwsUtilities.Assert(
                name != null,
                "UserConfiguration.WriteUserConfigurationNameToXml",
                "name is null");
            EwsUtilities.Assert(
                parentFolderId != null,
                "UserConfiguration.WriteUserConfigurationNameToXml",
                "parentFolderId is null");

            writer.WriteStartElement(xmlNamespace, XmlElementNames.UserConfigurationName);

            writer.WriteAttributeValue(XmlAttributeNames.Name, name);

            parentFolderId.WriteToXml(writer);

            writer.WriteEndElement();
        }
 /// <summary>
 /// Writes to XML.
 /// </summary>
 /// <param name="writer">The writer.</param>
 internal virtual void WriteToXml(EwsServiceXmlWriter writer)
 {
     writer.WriteStartElement(XmlNamespace.Types, this.GetXmlElementName());
     this.WriteAttributesToXml(writer);
     writer.WriteEndElement();
 }
 /// <summary>
 /// Writes a dictionary entry type to Xml.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="dictionaryObjectType">Type to write.</param>
 private void WriteEntryTypeToXml(EwsServiceXmlWriter writer, UserConfigurationDictionaryObjectType dictionaryObjectType)
 {
     writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Type);
     writer.WriteValue(dictionaryObjectType.ToString(), XmlElementNames.Type);
     writer.WriteEndElement();
 }
Пример #55
0
        /// <summary>
        /// Writes XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName);
            writer.WriteAttributeValue("xmlns", EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, EwsUtilities.EwsXmlSchemaInstanceNamespace);
            writer.WriteAttributeValue("xmlns", EwsUtilities.EwsMessagesNamespacePrefix, EwsUtilities.EwsMessagesNamespace);
            writer.WriteAttributeValue("xmlns", EwsUtilities.EwsTypesNamespacePrefix, EwsUtilities.EwsTypesNamespace);
            if (writer.RequireWSSecurityUtilityNamespace)
            {
                writer.WriteAttributeValue("xmlns", EwsUtilities.WSSecurityUtilityNamespacePrefix, EwsUtilities.WSSecurityUtilityNamespace);
            }

            writer.WriteStartElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName);

            if (this.Service.Credentials != null)
            {
                this.Service.Credentials.EmitExtraSoapHeaderNamespaceAliases(writer.InternalWriter);
            }

            // Emit the RequestServerVersion header
            if (!this.Service.SuppressXmlVersionHeader)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.RequestServerVersion);
                writer.WriteAttributeValue(XmlAttributeNames.Version, this.GetRequestedServiceVersionString());
                writer.WriteEndElement(); // RequestServerVersion
            }

            // Against Exchange 2007 SP1, we always emit the simplified time zone header. It adds very little to
            // the request, so bandwidth consumption is not an issue. Against Exchange 2010 and above, we emit
            // the full time zone header but only when the request actually needs it.
            //
            // The exception to this is if we are in Exchange2007 Compat Mode, in which case we should never emit
            // the header.  (Note: Exchange2007 Compat Mode is enabled for testability purposes only.)
            //
            if ((this.Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1 || this.EmitTimeZoneHeader) &&
                (!this.Service.Exchange2007CompatibilityMode))
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.TimeZoneContext);

                this.Service.TimeZoneDefinition.WriteToXml(writer);

                writer.WriteEndElement(); // TimeZoneContext

                writer.IsTimeZoneHeaderEmitted = true;
            }

            // Emit the MailboxCulture header
            if (this.Service.PreferredCulture != null)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MailboxCulture,
                    this.Service.PreferredCulture.Name);
            }

            // Emit the DateTimePrecision header
            if (this.Service.DateTimePrecision != DateTimePrecision.Default)
            {
                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.DateTimePrecision,
                    this.Service.DateTimePrecision.ToString());
            }

            // Emit the ExchangeImpersonation header
            if (this.Service.ImpersonatedUserId != null)
            {
                this.Service.ImpersonatedUserId.WriteToXml(writer);
            }
            else if (this.Service.PrivilegedUserId != null)
            {
                this.Service.PrivilegedUserId.WriteToXml(writer, this.Service.RequestedServerVersion);
            }
            else if (this.Service.ManagementRoles != null)
            {
                this.Service.ManagementRoles.WriteToXml(writer);
            }

            if (this.Service.Credentials != null)
            {
                this.Service.Credentials.SerializeExtraSoapHeaders(writer.InternalWriter, this.GetXmlElementName());
            }

            this.Service.DoOnSerializeCustomSoapHeaders(writer.InternalWriter);

            writer.WriteEndElement(); // soap:Header

            writer.WriteStartElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName);

            this.WriteBodyToXml(writer);

            writer.WriteEndElement(); // soap:Body
            writer.WriteEndElement(); // soap:Envelope
        }
        /// <summary>
        /// Writes a dictionary entry value to Xml.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="value">Value to write.</param>
        private void WriteEntryValueToXml(EwsServiceXmlWriter writer, string value)
        {
            writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Value);

            // While an entry value can't be null, if the entry is an array, an element of the array can be null.
            if (value != null)
            {
                writer.WriteValue(value, XmlElementNames.Value);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes request to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            writer.WriteStartElement(XmlNamespace.Autodiscover, XmlElementNames.Request);

            writer.WriteStartElement(XmlNamespace.Autodiscover, XmlElementNames.Domains);

            foreach (string domain in this.Domains)
            {
                if (!string.IsNullOrEmpty(domain))
                {
                    writer.WriteElementValue(
                        XmlNamespace.Autodiscover,
                        XmlElementNames.Domain,
                        domain);
                }
            }
            writer.WriteEndElement(); // Domains

            writer.WriteStartElement(XmlNamespace.Autodiscover, XmlElementNames.RequestedSettings);
            foreach (DomainSettingName setting in settings)
            {
                writer.WriteElementValue(
                    XmlNamespace.Autodiscover,
                    XmlElementNames.Setting,
                    setting);
            }

            writer.WriteEndElement(); // RequestedSettings

            if (this.requestedVersion.HasValue)
            {
                writer.WriteElementValue(XmlNamespace.Autodiscover, XmlElementNames.RequestedVersion, this.requestedVersion.Value);
            }

            writer.WriteEndElement(); // Request
        }
Пример #58
0
        /// <summary>
        /// WriteRolesToXml
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="roles"></param>
        /// <param name="elementName"></param>
        private void WriteRolesToXml(EwsServiceXmlWriter writer, string[] roles, string elementName)
        {
            if (roles != null)
            {
                writer.WriteStartElement(XmlNamespace.Types, elementName);

                foreach (string role in roles)
                {
                    writer.WriteElementValue(XmlNamespace.Types, XmlElementNames.Role, role);
                }

                writer.WriteEndElement();
            }
        }
        /// <summary>
        /// Writes elements to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal override void WriteElementsToXml(EwsServiceXmlWriter writer)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfigurationDictionary.WriteElementsToXml",
                "writer is null");

            foreach (KeyValuePair<object, object> dictionaryEntry in this.dictionary)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.DictionaryEntry);

                this.WriteObjectToXml(
                    writer,
                    XmlElementNames.DictionaryKey,
                    dictionaryEntry.Key);

                this.WriteObjectToXml(
                    writer,
                    XmlElementNames.DictionaryValue,
                    dictionaryEntry.Value);

                writer.WriteEndElement();
            }
        }
        /// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="request">The request being emitted.</param>
        internal void WriteToXml(EwsServiceXmlWriter writer, GetUserAvailabilityRequest request)
        {
            if (request.IsFreeBusyViewRequested)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.FreeBusyViewOptions);

                request.TimeWindow.WriteToXmlUnscopedDatesOnly(writer, XmlElementNames.TimeWindow);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MergedFreeBusyIntervalInMinutes,
                    this.MergedFreeBusyInterval);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.RequestedView,
                    this.RequestedFreeBusyView);

                writer.WriteEndElement(); // FreeBusyViewOptions
            }

            if (request.IsSuggestionsViewRequested)
            {
                writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.SuggestionsViewOptions);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.GoodThreshold,
                    this.GoodSuggestionThreshold);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MaximumResultsByDay,
                    this.MaximumSuggestionsPerDay);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MaximumNonWorkHourResultsByDay,
                    this.MaximumNonWorkHoursSuggestionsPerDay);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MeetingDurationInMinutes,
                    this.MeetingDuration);

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.MinimumSuggestionQuality,
                    this.MinimumSuggestionQuality);

                TimeWindow timeWindowToSerialize = this.DetailedSuggestionsWindow == null ?
                    request.TimeWindow :
                    this.DetailedSuggestionsWindow;

                timeWindowToSerialize.WriteToXmlUnscopedDatesOnly(writer, XmlElementNames.DetailedSuggestionsWindow);

                if (this.CurrentMeetingTime.HasValue)
                {
                    writer.WriteElementValue(
                        XmlNamespace.Types,
                        XmlElementNames.CurrentMeetingTime,
                        this.CurrentMeetingTime.Value);
                }

                writer.WriteElementValue(
                    XmlNamespace.Types,
                    XmlElementNames.GlobalObjectId,
                    this.GlobalObjectId);

                writer.WriteEndElement(); // SuggestionsViewOptions
            }
        }