/// <summary> /// Read XML element. /// </summary> /// <param name="xmlNamespace">The XML namespace.</param> /// <param name="localName">Name of the local.</param> /// <param name="nodeType">Type of the node.</param> private void InternalReadElement( XmlNamespace xmlNamespace, string localName, XmlNodeType nodeType) { if (xmlNamespace == XmlNamespace.NotSpecified) { this.InternalReadElement( string.Empty, localName, nodeType); } else { this.Read(nodeType); if ((this.LocalName != localName) || (this.NamespaceUri != EwsUtilities.GetNamespaceUri(xmlNamespace))) { throw new ServiceXmlDeserializationException( string.Format( Strings.UnexpectedElement, EwsUtilities.GetNamespacePrefix(xmlNamespace), localName, nodeType, this.xmlReader.Name, this.NodeType)); } } }
/// <summary> /// Writes the start element. /// </summary> /// <param name="xmlNamespace">The XML namespace.</param> /// <param name="localName">The local name of the element.</param> public void WriteStartElement(XmlNamespace xmlNamespace, string localName) { this.xmlWriter.WriteStartElement( EwsUtilities.GetNamespacePrefix(xmlNamespace), localName, EwsUtilities.GetNamespaceUri(xmlNamespace)); }
/// <summary> /// Read XML element. /// </summary> /// <param name="xmlNamespace">The XML namespace.</param> /// <param name="localName">Name of the local.</param> /// <param name="nodeType">Type of the node.</param> private async System.Threading.Tasks.Task InternalReadElementAsync( XmlNamespace xmlNamespace, string localName, XmlNodeType nodeType, CancellationToken token) { if (xmlNamespace == XmlNamespace.NotSpecified) { this.InternalReadElement( string.Empty, localName, nodeType); } else { await this.ReadAsync(nodeType, token); if ((this.LocalName != localName) || (this.NamespaceUri != EwsUtilities.GetNamespaceUri(xmlNamespace))) { throw new ServiceXmlDeserializationException( string.Format( Strings.UnexpectedElement, EwsUtilities.GetNamespacePrefix(xmlNamespace), localName, nodeType, this.xmlReader.Name, this.NodeType)); } } }
void ReadElementsFromXml(EwsServiceXmlReader reader) { this.Manifests.Clear(); base.ReadElementsFromXml(reader); reader.Read(XmlNodeType.Element); // We can have a response from Exchange 2013 (first time this API was introduced) // or the newer response, starting in Exchange 2013 SP1, (X-EWS-TargetVersion: 2.5 or above) bool exchange2013Response; if (XmlElementNames.Manifests.Equals(reader.LocalName)) { exchange2013Response = true; } else if (XmlElementNames.Apps.Equals(reader.LocalName)) { exchange2013Response = false; } else { throw new ServiceXmlDeserializationException( string.Format( Strings.UnexpectedElement, EwsUtilities.GetNamespacePrefix(XmlNamespace.Messages), XmlElementNames.Manifests, XmlNodeType.Element, reader.LocalName, reader.NodeType)); } if (!reader.IsEmptyElement) { // Because we don't have an element for count of returned object, // we have to test the element to determine if it is StartElement of return object or EndElement reader.Read(); if (exchange2013Response) { this.ReadFromExchange2013(reader); } else { this.ReadFromExchange2013Sp1(reader); } } reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, exchange2013Response ? XmlElementNames.Manifests : XmlElementNames.Apps); }
/// <summary> /// Determines whether current element is a end element. /// </summary> /// <param name="xmlNamespace">The XML namespace.</param> /// <param name="localName">Name of the local.</param> /// <returns> /// <c>true</c> if current element is an end element; otherwise, <c>false</c>. /// </returns> public bool IsEndElement(XmlNamespace xmlNamespace, string localName) { return((this.LocalName == localName) && (this.NodeType == XmlNodeType.EndElement) && ((this.NamespacePrefix == EwsUtilities.GetNamespacePrefix(xmlNamespace)) || (this.NamespaceUri == EwsUtilities.GetNamespaceUri(xmlNamespace)))); }
/// <summary> /// Determines whether current element is a start element. /// </summary> /// <param name="xmlNamespace">The XML namespace.</param> /// <param name="localName">Name of the local.</param> /// <returns> /// <c>true</c> if current element is a start element; otherwise, <c>false</c>. /// </returns> public bool IsStartElement(XmlNamespace xmlNamespace, string localName) { return((this.LocalName == localName) && this.IsStartElement() && ((this.NamespacePrefix == EwsUtilities.GetNamespacePrefix(xmlNamespace)) || (this.NamespaceUri == EwsUtilities.GetNamespaceUri(xmlNamespace)))); }