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(_xmlElementName)) {
    _xmlElementName = GetXmlElementNameOverride();

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

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

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

  return _xmlElementName;
}