TryReadElementFromXml method

  1. @override
Future<bool> TryReadElementFromXml(
  1. EwsServiceXmlReader reader
)
override
Tries to read element from XML. The reader.

Implementation

@override
Future<bool> TryReadElementFromXml(EwsServiceXmlReader reader) async {
  switch (reader.LocalName) {
    case XmlElementNames.ExtendedFieldURI:
      this._propertyDefinition = new ExtendedPropertyDefinition();
      await this._propertyDefinition!.LoadFromXml(reader);
      return true;
    case XmlElementNames.Value:
      EwsUtilities.Assert(
          this.PropertyDefinition != null,
          "ExtendedProperty.TryReadElementFromXml",
          "PropertyDefintion is missing");

      String? stringValue = await reader.ReadElementValue<String>();
      this._value = MapiTypeConverter.ConvertToValueWithStringValue(
          this.PropertyDefinition!.MapiType, stringValue);
      return true;
    case XmlElementNames.Values:
      EwsUtilities.Assert(
          this.PropertyDefinition != null,
          "ExtendedProperty.TryReadElementFromXml",
          "PropertyDefintion is missing");

      StringList stringList =
          new StringList.fromElementName(XmlElementNames.Value);
      await stringList.LoadFromXml(reader, reader.LocalName);
      this._value = MapiTypeConverter.ConvertToValue(
          this.PropertyDefinition!.MapiType, stringList);
      return true;
    default:
      return false;
  }
}