GetXmlElementName method

String? GetXmlElementName()
GetXmlElementName retrieves the XmlElementName of this type based on the EwsObjectDefinition attribute that decorates it, if present.

Implementation

String? GetXmlElementName() {
  if (StringUtils.IsNullOrEmpty(this._xmlElementName)) {
    this._xmlElementName = this.GetXmlElementNameOverride();

    if (StringUtils.IsNullOrEmpty(this._xmlElementName)) {
      this._lockObject.synchronized(() {
//                        for (Attribute attribute in this.GetType().GetCustomAttributes(false))
//                        {
        ServiceObjectDefinitionAttribute? definitionAttribute =
            getServiceObjectDefinitionAttribute(); // attribute as ServiceObjectDefinitionAttribute;

        if (definitionAttribute != null) {
          this._xmlElementName = definitionAttribute.XmlElementName;
        }
//                        }
      });
    }
  }

  EwsUtilities.Assert(
      !StringUtils.IsNullOrEmpty(this._xmlElementName),
      "EwsObject.GetXmlElementName",
      "The class ${this.runtimeType} does not have an associated XML element name.");

  return this._xmlElementName;
}