ReadElementsFromXml method
Reads response elements from XML.
The reader.
Implementation
@override
Future<void> ReadElementsFromXml(EwsServiceXmlReader reader) async {
this.Changes.SyncState = await reader.ReadElementValueWithNamespace(
XmlNamespace.Messages, XmlElementNames.SyncState);
this.Changes.MoreChangesAvailable =
!(await reader.ReadElementValueWithNamespace<bool>(
XmlNamespace.Messages,
this.GetIncludesLastInRangeXmlElementName()))!;
await reader.ReadStartElementWithNamespace(
XmlNamespace.Messages, XmlElementNames.Changes);
if (!reader.IsEmptyElement) {
do {
await reader.Read();
if (reader.IsStartElement()) {
TChange change = this.CreateChangeInstance();
switch (reader.LocalName) {
case XmlElementNames.Create:
change.ChangeType = ChangeType.Create;
break;
case XmlElementNames.Update:
change.ChangeType = ChangeType.Update;
break;
case XmlElementNames.Delete:
change.ChangeType = ChangeType.Delete;
break;
case XmlElementNames.ReadFlagChange:
change.ChangeType = ChangeType.ReadFlagChange;
break;
default:
await reader.SkipCurrentElement();
break;
}
if (change != null) {
await reader.Read();
reader.EnsureCurrentNodeIsStartElement();
switch (change.ChangeType) {
case ChangeType.Delete:
case ChangeType.ReadFlagChange:
change.Id = change.CreateId();
await change.Id!
.LoadFromXml(reader, change.Id!.GetXmlElementName());
if (change.ChangeType == ChangeType.ReadFlagChange) {
await reader.Read();
reader.EnsureCurrentNodeIsStartElement();
ItemChange itemChange = change as ItemChange;
EwsUtilities.Assert(
itemChange != null,
"SyncResponse.ReadElementsFromXml",
"ReadFlagChange is only valid on ItemChange");
itemChange.IsRead =
await reader.ReadElementValueWithNamespace<bool>(
XmlNamespace.Types, XmlElementNames.IsRead);
}
break;
default:
change.ServiceObject =
EwsUtilities.CreateEwsObjectFromXmlElementName<
TServiceObject>(reader.Service, reader.LocalName);
await change.ServiceObject!.LoadFromXmlWithPropertySet(
reader,
true,
/* clearPropertyBag */
this._propertySet,
this.SummaryPropertiesOnly);
break;
}
await reader.ReadEndElementIfNecessary(
XmlNamespace.Types, EnumToString.parse(change.ChangeType));
this._changes.Add(change);
}
}
} while (!reader.IsEndElementWithNamespace(
XmlNamespace.Messages, XmlElementNames.Changes));
}
}