LoadFromXml method
Loads response from XML.
The reader.
Name of the XML element.
Implementation
void LoadFromXml(EwsServiceXmlReader reader, String xmlElementName) {
if (!reader.IsStartElementWithNamespace(
XmlNamespace.Messages, xmlElementName)) {
reader.ReadStartElementWithNamespace(
XmlNamespace.Messages, xmlElementName);
}
this._result = reader.ReadAttributeValue<ServiceResult>(
XmlAttributeNames.ResponseClass);
if (this._result == ServiceResult.Success ||
this._result == ServiceResult.Warning) {
if (this._result == ServiceResult.Warning) {
this._errorMessage = reader.ReadElementValueWithNamespace(
XmlNamespace.Messages, XmlElementNames.MessageText);
}
this._errorCode = reader.ReadElementValueWithNamespace<ServiceError>(
XmlNamespace.Messages, XmlElementNames.ResponseCode);
if (this._result == ServiceResult.Warning) {
reader.ReadElementValueWithNamespace<int>(
XmlNamespace.Messages, XmlElementNames.DescriptiveLinkKey);
}
// If batch processing stopped, EWS returns an empty element. Skip over it.
if (this.BatchProcessingStopped) {
do {
reader.Read();
} while (!reader.IsEndElementWithNamespace(
XmlNamespace.Messages, xmlElementName));
} else {
this.ReadElementsFromXml(reader);
reader.ReadEndElementIfNecessary(XmlNamespace.Messages, xmlElementName);
}
} else {
this._errorMessage = reader.ReadElementValueWithNamespace(
XmlNamespace.Messages, XmlElementNames.MessageText);
this._errorCode = reader.ReadElementValueWithNamespace<ServiceError>(
XmlNamespace.Messages, XmlElementNames.ResponseCode);
reader.ReadElementValueWithNamespace<int>(
XmlNamespace.Messages, XmlElementNames.DescriptiveLinkKey);
while (!reader.IsEndElementWithNamespace(
XmlNamespace.Messages, xmlElementName)) {
reader.Read();
if (reader.IsStartElement()) {
if (!this.LoadExtraErrorDetailsFromXml(reader, reader.LocalName)) {
reader.SkipCurrentElement();
}
}
}
}
this.MapErrorCodeToErrorMessage();
this.Loaded();
}