DeviceLockerInfo.fromXML constructor

DeviceLockerInfo.fromXML(
  1. String xmlSTR
)

Implementation

factory DeviceLockerInfo.fromXML(String xmlSTR) {
  final document = XmlDocument.parse(xmlSTR);

  XmlElement? ipAndPortElement = document.firstChild!.getElement("ipAndPort");
  XmlElement? applicationListElement =
      document.firstChild!.getElement("applicationList");
  List<XmlElement> applications =
      applicationListElement!.findElements("application").toList();
  IpAndPort ipAndPort = IpAndPort.fromXML(ipAndPortElement!.toXmlString());
  String lockMethod = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "lockMethod")
      .value;
  List<Application> applicationList =
      applications.map((e) => Application.fromXML(e.toXmlString())).toList();
  return DeviceLockerInfo(
      ipAndPort: ipAndPort,
      lockMethod: lockMethod,
      applicationList: applicationList);
}