ReadServiceObjectsCollectionFromXmlWithNamespace<TServiceObject extends ServiceObject> method

Future<List<TServiceObject>> ReadServiceObjectsCollectionFromXmlWithNamespace<TServiceObject extends ServiceObject>(
  1. XmlNamespace collectionXmlNamespace,
  2. String collectionXmlElementName,
  3. IGetObjectInstanceDelegate<TServiceObject> getObjectInstanceDelegate,
  4. bool clearPropertyBag,
  5. PropertySet? requestedPropertySet,
  6. bool summaryPropertiesOnly,
)
Reads the service objects collection from XML. Namespace of the collection XML element. Name of the collection XML element. The get object instance delegate. if set to [clear property bag]. The requested property set. if set to [summary properties only].

Implementation

Future<List<TServiceObject>> ReadServiceObjectsCollectionFromXmlWithNamespace<
  TServiceObject extends ServiceObject
>(
  XmlNamespace collectionXmlNamespace,
  String collectionXmlElementName,
  IGetObjectInstanceDelegate<TServiceObject> getObjectInstanceDelegate,
  bool clearPropertyBag,
  PropertySet? requestedPropertySet,
  bool summaryPropertiesOnly,
) async {
  List<TServiceObject> serviceObjects = <TServiceObject>[];
  TServiceObject? serviceObject;

  if (!IsStartElementWithNamespace(
    collectionXmlNamespace,
    collectionXmlElementName,
  )) {
    await ReadStartElementWithNamespace(
      collectionXmlNamespace,
      collectionXmlElementName,
    );
  }

  if (!IsEmptyElement) {
    do {
      await Read();

      if (IsStartElement()) {
        serviceObject = getObjectInstanceDelegate(Service, LocalName);

        if (LocalName != serviceObject.GetXmlElementName()) {
          throw ServiceLocalException(
            "The type of the object in the store ($LocalName) does not match that of the local object (${serviceObject.GetXmlElementName()}).",
          );
        }

        await serviceObject.LoadFromXmlWithPropertySet(
          this,
          clearPropertyBag,
          requestedPropertySet,
          summaryPropertiesOnly,
        );

        serviceObjects.add(serviceObject);
      }
    } while (!IsEndElementWithNamespace(
      collectionXmlNamespace,
      collectionXmlElementName,
    ));
  }

  return serviceObjects;
}