DBusIntrospectProperty.fromXml constructor

DBusIntrospectProperty.fromXml(
  1. XmlNode node
)

Implementation

factory DBusIntrospectProperty.fromXml(XmlNode node) {
  var name = node.getAttribute('name');
  if (name == null) {
    throw FormatException('D-Bus Introspection XML missing property name');
  }
  var typeString = node.getAttribute('type');
  if (typeString == null) {
    throw FormatException('D-Bus Introspection XML missing property type');
  }
  var type = DBusSignature(typeString);
  var accessText = node.getAttribute('access');
  var access = {
    null: DBusPropertyAccess.readwrite,
    'readwrite': DBusPropertyAccess.readwrite,
    'read': DBusPropertyAccess.read,
    'write': DBusPropertyAccess.write
  }[accessText];
  if (access == null) {
    throw FormatException("Unknown property access '$accessText'");
  }
  var annotations = node
      .findElements('annotation')
      .map((n) => DBusIntrospectAnnotation.fromXml(n))
      .toList();
  return DBusIntrospectProperty(name, type,
      access: access, annotations: annotations);
}