deserialize method

  1. @override
void deserialize(
  1. XmlElement xml
)
override

Deserializes the FML template elements, attributes and children

Implementation

@override
void deserialize(XmlElement xml)
{
  // deserialize
  super.deserialize(xml);

  rowcount = 0;

  // properties
  queuetype = Xml.get(node: xml, tag: 'queuetype');
  timetolive = Xml.get(node: xml, tag: 'ttl');
  timetoidle = S.toInt(Xml.get(node: xml, tag: 'tti'));
  autoexecute = Xml.get(node: xml, tag: 'autoexecute');
  autoquery = Xml.get(node: xml, tag: 'autoquery');
  onsuccess = Xml.get(node: xml, tag: 'onsuccess');
  onreadsuccess = Xml.get(node: xml, tag: 'onreadsuccess');
  onwritesuccess = Xml.get(node: xml, tag: 'onwritesuccess');
  onfail = Xml.get(node: xml, tag: 'onfail');
  statuscode = Xml.get(node: xml, tag: 'statuscode');
  statusmessage = Xml.get(node: xml, tag: 'statusmessage');
  maxrecords = Xml.get(node: xml, tag: 'maxrecords');
  root = Xml.attribute(node: xml, tag: 'root');
  value = Xml.get(node: xml, tag: 'value');

  // custom body defined?
  XmlElement? body = Xml.getChildElement(node: xml, tag: 'body');
  if (body != null)
  {
    // set body type
    _custombody = true;

    // body is all text (cdata or text only)?
    bool isText = (body.children.firstWhereOrNull((child) => (child is XmlCDATA || child is XmlText || child is XmlComment) ? false : true) == null);
    if (isText) {
      this.body = body.innerText.trim();
    } else {
      this.body = body.innerXml.trim();
    }
  }

  // This Line Ensures Future Bodies that Contain Bindables won't Bind
  if (_body == null) this.body = "";

  // register the datasource with the scope manager
  if (scope != null) scope!.registerDataSource(this);

  // disable the datasource when the framework isn't active (i.e. top of stack)
  bool? runInBackground = S.toBool(Xml.get(node: xml, tag: 'background'));
  if ((runInBackground == false) &&
      (framework != null) &&
      (framework!.indexObservable != null)) {
    framework!.indexObservable!.registerListener(onIndexChange);
  }
}