LoadFromXml method

void LoadFromXml(
  1. EwsServiceXmlReader reader,
  2. bool clear,
  3. PropertySet? requestedPropertySet,
  4. bool onlySummaryPropertiesRequested,
)
Loads properties from XML and inserts them in the bag. The reader from which to read the properties. Indicates whether the bag should be cleared before properties are loaded. The requested property set. Indicates whether summary or full properties were requested.

Implementation

void LoadFromXml(EwsServiceXmlReader reader, bool clear,
    PropertySet? requestedPropertySet, bool onlySummaryPropertiesRequested) {
  if (clear) {
    this.Clear();
  }

  // Put the property bag in "loading" mode. When in loading mode, no checking is done
  // when setting property values.
  this._loading = true;

  this._requestedPropertySet = requestedPropertySet;
  this._onlySummaryPropertiesRequested = onlySummaryPropertiesRequested;

  try {
    do {
      reader.Read();

      if (reader.NodeType == XmlNodeType.Element) {
        OutParam<PropertyDefinition> propertyDefinitionOutParam =
            new OutParam<PropertyDefinition>();

        if (this.Owner!.Schema.TryGetPropertyDefinition(
            reader.LocalName, propertyDefinitionOutParam)) {
          PropertyDefinition propertyDefinition =
              propertyDefinitionOutParam.param!;
          propertyDefinition.LoadPropertyValueFromXml(reader, this);

          this._loadedProperties.add(propertyDefinition);
        } else {
          reader.SkipCurrentElement();
        }
      }
    } while (!reader.IsEndElementWithNamespace(
        XmlNamespace.Types, this.Owner!.GetXmlElementName()));

    this.ClearChangeLog();
  } finally {
    this._loading = false;
  }
}