/// <summary> /// Parses the XML through the specified reader and creates an Autodiscover error. /// </summary> /// <param name="reader">The reader.</param> /// <returns>An Autodiscover error.</returns> internal static AutodiscoverError Parse(EwsXmlReader reader) { AutodiscoverError error = new AutodiscoverError(); error.time = reader.ReadAttributeValue(XmlAttributeNames.Time); error.id = reader.ReadAttributeValue(XmlAttributeNames.Id); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: error.errorCode = reader.ReadElementValue<int>(); break; case XmlElementNames.Message: error.message = reader.ReadElementValue(); break; case XmlElementNames.DebugData: error.debugData = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Error)); return error; }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.DisplayName: this.displayName = reader.ReadElementValue(); break; case XmlElementNames.LegacyDN: this.legacyDN = reader.ReadElementValue(); break; case XmlElementNames.DeploymentId: this.deploymentId = reader.ReadElementValue(); break; case XmlElementNames.AutoDiscoverSMTPAddress: this.autodiscoverAMTPAddress = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.User)); }
/// <summary> /// Loads the settings from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.Autodiscover); reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.Response); do { reader.Read(); if (reader.IsStartElement()) { if (!this.TryReadCurrentXmlElement(reader)) { reader.SkipCurrentElement(); } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Response)); reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.Autodiscover); }
/// <summary> /// Loads the settings from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.Autodiscover); reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.Response); do { reader.Read(); if (reader.IsStartElement()) { if (!this.TryReadCurrentXmlElement(reader)) { reader.SkipCurrentElement(); } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Response)); reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.Autodiscover); }
/// <summary> /// Parses the XML through the specified reader and creates an Autodiscover error. /// </summary> /// <param name="reader">The reader.</param> /// <returns>An Autodiscover error.</returns> internal static AutodiscoverError Parse(EwsXmlReader reader) { AutodiscoverError error = new AutodiscoverError(); error.time = reader.ReadAttributeValue(XmlAttributeNames.Time); error.id = reader.ReadAttributeValue(XmlAttributeNames.Id); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: error.errorCode = reader.ReadElementValue <int>(); break; case XmlElementNames.Message: error.message = reader.ReadElementValue(); break; case XmlElementNames.DebugData: error.debugData = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Error)); return(error); }
/// <summary> /// Loads web client urls from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="webClientUrls">The web client urls.</param> /// <param name="elementName">Name of the element.</param> private static void LoadWebClientUrlsFromXml(EwsXmlReader reader, WebClientUrlCollection webClientUrls, string elementName) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.OWAUrl: string authMethod = reader.ReadAttributeValue(XmlAttributeNames.AuthenticationMethod); string owaUrl = reader.ReadElementValue(); WebClientUrl webClientUrl = new WebClientUrl(authMethod, owaUrl); webClientUrls.Urls.Add(webClientUrl); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, elementName)); }
/// <summary> /// Tries to read the current XML element. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True is the current element was read, false otherwise.</returns> internal override bool TryReadCurrentXmlElement(EwsXmlReader reader) { if (!base.TryReadCurrentXmlElement(reader)) { switch (reader.LocalName) { case XmlElementNames.User: this.user.LoadFromXml(reader); return(true); case XmlElementNames.Account: this.account.LoadFromXml(reader); return(true); default: reader.SkipCurrentElement(); return(false); } } else { return(true); } }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.AccountType: this.AccountType = reader.ReadElementValue(); break; case XmlElementNames.Action: string xmlResponseType = reader.ReadElementValue(); switch (xmlResponseType) { case OutlookAccount.Settings: this.ResponseType = AutodiscoverResponseType.Success; break; case OutlookAccount.RedirectUrl: this.ResponseType = AutodiscoverResponseType.RedirectUrl; break; case OutlookAccount.RedirectAddr: this.ResponseType = AutodiscoverResponseType.RedirectAddress; break; default: this.ResponseType = AutodiscoverResponseType.Error; break; } break; case XmlElementNames.Protocol: OutlookProtocol protocol = new OutlookProtocol(); protocol.LoadFromXml(reader); if (this.protocols.ContainsKey(protocol.ProtocolType)) { // There should be strictly one node per protocol type in the autodiscover response. throw new ServiceLocalException(Strings.InvalidAutodiscoverServiceResponse); } this.protocols.Add(protocol.ProtocolType, protocol); break; case XmlElementNames.RedirectAddr: case XmlElementNames.RedirectUrl: this.RedirectTarget = reader.ReadElementValue(); break; case XmlElementNames.AlternateMailboxes: AlternateMailbox alternateMailbox = AlternateMailbox.LoadFromXml(reader); this.alternateMailboxes.Entries.Add(alternateMailbox); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Account)); }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.DisplayName: this.displayName = reader.ReadElementValue(); break; case XmlElementNames.LegacyDN: this.legacyDN = reader.ReadElementValue(); break; case XmlElementNames.DeploymentId: this.deploymentId = reader.ReadElementValue(); break; case XmlElementNames.AutoDiscoverSMTPAddress: this.autodiscoverAMTPAddress = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.User)); }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.AccountType: this.AccountType = reader.ReadElementValue(); break; case XmlElementNames.Action: string xmlResponseType = reader.ReadElementValue(); switch (xmlResponseType) { case OutlookAccount.Settings: this.ResponseType = AutodiscoverResponseType.Success; break; case OutlookAccount.RedirectUrl: this.ResponseType = AutodiscoverResponseType.RedirectUrl; break; case OutlookAccount.RedirectAddr: this.ResponseType = AutodiscoverResponseType.RedirectAddress; break; default: this.ResponseType = AutodiscoverResponseType.Error; break; } break; case XmlElementNames.Protocol: OutlookProtocol protocol = new OutlookProtocol(); protocol.LoadFromXml(reader); if (this.protocols.ContainsKey(protocol.ProtocolType)) { // There should be strictly one node per protocol type in the autodiscover response. throw new ServiceLocalException(Strings.InvalidAutodiscoverServiceResponse); } this.protocols.Add(protocol.ProtocolType, protocol); break; case XmlElementNames.RedirectAddr: case XmlElementNames.RedirectUrl: this.RedirectTarget = reader.ReadElementValue(); break; case XmlElementNames.AlternateMailboxes: AlternateMailbox alternateMailbox = AlternateMailbox.LoadFromXml(reader); this.alternateMailboxes.Entries.Add(alternateMailbox); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Account)); }
/// <summary> /// Tries to read the current XML element. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True is the current element was read, false otherwise.</returns> internal override bool TryReadCurrentXmlElement(EwsXmlReader reader) { if (!base.TryReadCurrentXmlElement(reader)) { switch (reader.LocalName) { case XmlElementNames.User: this.user.LoadFromXml(reader); return true; case XmlElementNames.Account: this.account.LoadFromXml(reader); return true; default: reader.SkipCurrentElement(); return false; } } else { return true; } }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Type: this.ProtocolType = OutlookProtocol.ProtocolNameToType(reader.ReadElementValue()); break; case XmlElementNames.AuthPackage: this.authPackage = reader.ReadElementValue(); break; case XmlElementNames.Server: this.server = reader.ReadElementValue(); break; case XmlElementNames.ServerDN: this.serverDN = reader.ReadElementValue(); break; case XmlElementNames.ServerVersion: // just read it out reader.ReadElementValue(); break; case XmlElementNames.AD: this.activeDirectoryServer = reader.ReadElementValue(); break; case XmlElementNames.MdbDN: this.mailboxDN = reader.ReadElementValue(); break; case XmlElementNames.EWSUrl: this.exchangeWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.EmwsUrl: this.exchangeManagementWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.ASUrl: this.availabilityServiceUrl = reader.ReadElementValue(); break; case XmlElementNames.OOFUrl: // just read it out reader.ReadElementValue(); break; case XmlElementNames.UMUrl: this.unifiedMessagingUrl = reader.ReadElementValue(); break; case XmlElementNames.OABUrl: this.offlineAddressBookUrl = reader.ReadElementValue(); break; case XmlElementNames.PublicFolderServer: this.publicFolderServer = reader.ReadElementValue(); break; case XmlElementNames.Internal: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.internalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.External: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.externalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.Ssl: string sslStr = reader.ReadElementValue(); this.sslEnabled = sslStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.SharingUrl: this.sharingEnabled = reader.ReadElementValue().Length > 0; break; case XmlElementNames.EcpUrl: this.ecpUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_um: this.ecpUrlUm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_aggr: this.ecpUrlAggr = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_sms: this.ecpUrlSms = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_mt: this.ecpUrlMt = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_ret: this.ecpUrlRet = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_publish: this.ecpUrlPublish = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_photo: this.ecpUrlPhoto = reader.ReadElementValue(); break; case XmlElementNames.ExchangeRpcUrl: this.exchangeRpcUrl = reader.ReadElementValue(); break; case XmlElementNames.EwsPartnerUrl: this.exchangeWebServicesPartnerUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_connect: this.ecpUrlConnect = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tm: this.ecpUrlTm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmCreating: this.ecpUrlTmCreating = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmEditing: this.ecpUrlTmEditing = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmHiding: this.ecpUrlTmHiding = reader.ReadElementValue(); break; case XmlElementNames.SiteMailboxCreationURL: this.siteMailboxCreationURL = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_extinstall: this.ecpUrlExtInstall = reader.ReadElementValue(); break; case XmlElementNames.ServerExclusiveConnect: string serverExclusiveConnectStr = reader.ReadElementValue(); this.serverExclusiveConnect = serverExclusiveConnectStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.CertPrincipalName: this.certPrincipalName = reader.ReadElementValue(); break; case XmlElementNames.GroupingInformation: this.groupingInformation = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Protocol)); }
/// <summary> /// Loads web client urls from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="webClientUrls">The web client urls.</param> /// <param name="elementName">Name of the element.</param> private static void LoadWebClientUrlsFromXml(EwsXmlReader reader, WebClientUrlCollection webClientUrls, string elementName) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.OWAUrl: string authMethod = reader.ReadAttributeValue(XmlAttributeNames.AuthenticationMethod); string owaUrl = reader.ReadElementValue(); WebClientUrl webClientUrl = new WebClientUrl(authMethod, owaUrl); webClientUrls.Urls.Add(webClientUrl); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, elementName)); }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Type: this.ProtocolType = OutlookProtocol.ProtocolNameToType(reader.ReadElementValue()); break; case XmlElementNames.AuthPackage: this.authPackage = reader.ReadElementValue(); break; case XmlElementNames.Server: this.server = reader.ReadElementValue(); break; case XmlElementNames.ServerDN: this.serverDN = reader.ReadElementValue(); break; case XmlElementNames.ServerVersion: // just read it out reader.ReadElementValue(); break; case XmlElementNames.AD: this.activeDirectoryServer = reader.ReadElementValue(); break; case XmlElementNames.MdbDN: this.mailboxDN = reader.ReadElementValue(); break; case XmlElementNames.EWSUrl: this.exchangeWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.EmwsUrl: this.exchangeManagementWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.ASUrl: this.availabilityServiceUrl = reader.ReadElementValue(); break; case XmlElementNames.OOFUrl: // just read it out reader.ReadElementValue(); break; case XmlElementNames.UMUrl: this.unifiedMessagingUrl = reader.ReadElementValue(); break; case XmlElementNames.OABUrl: this.offlineAddressBookUrl = reader.ReadElementValue(); break; case XmlElementNames.PublicFolderServer: this.publicFolderServer = reader.ReadElementValue(); break; case XmlElementNames.Internal: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.internalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.External: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.externalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.Ssl: string sslStr = reader.ReadElementValue(); this.sslEnabled = sslStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.SharingUrl: this.sharingEnabled = reader.ReadElementValue().Length > 0; break; case XmlElementNames.EcpUrl: this.ecpUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_um: this.ecpUrlUm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_aggr: this.ecpUrlAggr = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_sms: this.ecpUrlSms = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_mt: this.ecpUrlMt = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_ret: this.ecpUrlRet = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_publish: this.ecpUrlPublish = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_photo: this.ecpUrlPhoto = reader.ReadElementValue(); break; case XmlElementNames.ExchangeRpcUrl: this.exchangeRpcUrl = reader.ReadElementValue(); break; case XmlElementNames.EwsPartnerUrl: this.exchangeWebServicesPartnerUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_connect: this.ecpUrlConnect = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tm: this.ecpUrlTm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmCreating: this.ecpUrlTmCreating = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmEditing: this.ecpUrlTmEditing = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmHiding: this.ecpUrlTmHiding = reader.ReadElementValue(); break; case XmlElementNames.SiteMailboxCreationURL: this.siteMailboxCreationURL = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_extinstall: this.ecpUrlExtInstall = reader.ReadElementValue(); break; case XmlElementNames.ServerExclusiveConnect: string serverExclusiveConnectStr = reader.ReadElementValue(); this.serverExclusiveConnect = serverExclusiveConnectStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.CertPrincipalName: this.certPrincipalName = reader.ReadElementValue(); break; case XmlElementNames.GroupingInformation: this.groupingInformation = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Protocol)); }