/// <summary> /// Reads user setting from XML. /// </summary> /// <param name="reader">The reader.</param> private void ReadSettingFromXml(EwsXmlReader reader) { string name = null; object value = null; do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Name: name = reader.ReadElementValue <string>(); break; case XmlElementNames.Value: value = reader.ReadElementValue(); break; case XmlElementNames.WebClientUrls: value = WebClientUrlCollection.LoadFromXml(reader); break; case XmlElementNames.ProtocolConnections: value = ProtocolConnectionCollection.LoadFromXml(reader); break; case XmlElementNames.AlternateMailboxes: value = AlternateMailboxCollection.LoadFromXml(reader); break; case XmlElementNames.DocumentSharingLocations: value = DocumentSharingLocationCollection.LoadFromXml(reader); break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.UserSetting)); // EWS Managed API is broken with AutoDSvc endpoint in RedirectUrl scenario try { UserSettingName userSettingName = EwsUtilities.Parse <UserSettingName>(name); this.Settings.Add(userSettingName, value); } catch (ArgumentException) { // ignore unexpected UserSettingName in the response (due to the server-side bugs). // it'd be better if this is hooked into ITraceListener, but that is unavailable here. // // in case "name" is null, EwsUtilities.Parse throws ArgumentNullException // (which derives from ArgumentException). // EwsUtilities.Assert( false, "GetUserSettingsResponse.ReadSettingFromXml", "Unexpected or empty name element in user setting"); } }
object Parse(String value) { // xs:list values are sent as a space-separated list; convert to comma-separated for EwsUtilities.Parse. String commaSeparatedValue = StringUtils.IsNullOrEmpty(value) ? value : value.Replace(' ', ','); return(EwsUtilities.Parse <TPropertyValue>(commaSeparatedValue)); }
/// <summary> /// Reads a nullable attribute value. /// </summary> /// <typeparam name="T">Type of attribute value.</typeparam> /// <param name="attributeName">Name of the attribute.</param> /// <returns>Attribute value.</returns> public Nullable <T> ReadNullableAttributeValue <T>(string attributeName) where T : struct { string attributeValue = this.ReadAttributeValue(attributeName); if (attributeValue == null) { return(null); } else { return(EwsUtilities.Parse <T>(attributeValue)); } }
/// <summary> /// Tries to read Status or Mailbox elements from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.Status: this.status = EwsUtilities.Parse <MemberStatus>(reader.ReadElementValue()); return(true); case XmlElementNames.Mailbox: this.AddressInformation = new EmailAddress(); this.AddressInformation.LoadFromXml(reader, reader.LocalName); return(true); default: return(false); } }
bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.NlgEmailPosition: String positionAsString = reader.ReadElementValue(); if (!StringUtils.IsNullOrEmpty(positionAsString)) { this.Position = EwsUtilities.Parse <EmailPosition>(positionAsString); } return(true); default: return(base.TryReadElementFromXml(reader)); } }
/// <summary> /// Reads the attributes from XML. /// </summary> /// <param name="reader">The reader.</param> internal override void ReadAttributesFromXml(EwsServiceXmlReader reader) { base.ReadAttributesFromXml(reader); this.EmailAddress.Name = reader.ReadAttributeValue <string>(XmlAttributeNames.Name); this.EmailAddress.RoutingType = reader.ReadAttributeValue <string>(XmlAttributeNames.RoutingType); string mailboxTypeString = reader.ReadAttributeValue(XmlAttributeNames.MailboxType); if (!string.IsNullOrEmpty(mailboxTypeString)) { this.EmailAddress.MailboxType = EwsUtilities.Parse <MailboxType>(mailboxTypeString); } else { this.EmailAddress.MailboxType = null; } }
/// <summary> /// Reads the enum value. /// </summary> /// <typeparam name="T">An enum type</typeparam> /// <param name="key">The key.</param> /// <returns></returns> internal T ReadEnumValue <T>(string key) { return(EwsUtilities.Parse <T>(this.ReadAsString(key))); }
/// <summary> /// Reads the value. /// </summary> /// <typeparam name="T">Type of value.</typeparam> /// <returns>Value.</returns> public T ReadValue <T>() { return(EwsUtilities.Parse <T>(this.ReadValue())); }
/// <summary> /// Reads the attribute value. /// </summary> /// <typeparam name="T">Type of attribute value.</typeparam> /// <param name="attributeName">Name of the attribute.</param> /// <returns>Attribute value.</returns> public T ReadAttributeValue <T>(string attributeName) { return(EwsUtilities.Parse <T>(this.ReadAttributeValue(attributeName))); }
/// <summary> /// Parses the specified value. /// </summary> /// <param name="value">The value.</param> /// <returns>Value of string.</returns> internal override object Parse(string value) { return(EwsUtilities.Parse <TPropertyValue>(value)); }