setAttributes method

bool setAttributes(
  1. Map<String, dynamic> attributes, [
  2. bool clearAttributes = false
])

Implementation

bool setAttributes(Map<String, dynamic> attributes,
    [bool clearAttributes = false]) {
  try {
    if (clearAttributes) _attributes.clear();

    for (var attrKey in attributes.keys)
      if (attrKey == "name")
        _name = attributes[attrKey] as String;
      else if (attrKey == "managers") {
        _managers.clear();

        var mngrs = attributes[attrKey] as List;
        // this is not implemented now, Flutter doesn't support mirrors, needs a workaround @ Warehouse.registerManager
        /*
                  for (var mngr in mngrs)
                  {
                      var m = mngr as Structure;
                      var type = Type.GetType(m["type"] as string);
                      if (Codec.implementsInterface<type, typeof(IPermissionsManager)))
                      {
                          var settings = m["settings"] as Structure;
                          var manager = Activator.CreateInstance(type) as IPermissionsManager;
                          manager.Initialize(settings, this.resource);
                          this.managers.Add(manager);
                      }
                      else
                          return false;
                  }
                  */
      } else {
        _attributes[attrKey] = attributes[attrKey];
      }
  } catch (ex) {
    return false;
  }

  return true;
}