CreateEwsObjectFromXmlElementName<TServiceObject extends ServiceObject> static method

TServiceObject CreateEwsObjectFromXmlElementName<TServiceObject extends ServiceObject>(
  1. ExchangeService? service,
  2. String xmlElementName
)
Creates EWS object based on XML element name. The service. Name of the XML element.

Implementation

static TServiceObject
    CreateEwsObjectFromXmlElementName<TServiceObject extends ServiceObject>(
        ExchangeService? service, String xmlElementName) {
  // todo("implement CreateEwsObjectFromXmlElementName");
//          print("CreateEwsObjectFromXmlElementName($xmlElementName);");

  if (EwsUtilities
      .serviceObjectInfo.Member!.XmlElementNameToServiceObjectClassMap
      .containsKey(xmlElementName)) {
    Type? itemClass = EwsUtilities.serviceObjectInfo.Member!
        .XmlElementNameToServiceObjectClassMap[xmlElementName];

    if (EwsUtilities
        .serviceObjectInfo.Member!.ServiceObjectConstructorsWithServiceParam
        .containsKey(itemClass)) {
      CreateServiceObjectWithServiceParam creationDelegate = EwsUtilities
          .serviceObjectInfo
          .Member!
          .ServiceObjectConstructorsWithServiceParam[itemClass!]!;
      return creationDelegate(service) as TServiceObject;
    } else {
      throw new ArgumentException(
          "Strings.NoAppropriateConstructorForItemClass");
    }
  } else {
    throw ArgumentException("Can't instantiate $TServiceObject");
//                return default(TServiceObject);
  }
}