Exemple #1
0
        public PermissionAttachment AddAttachment(IPlugin plugin, string name, bool value)
        {
            PermissionAttachment result = this.AddAttachment(plugin);

            result.SetPermission(name, value);

            this.RecalculatePermissions();
            return(result);
        }
Exemple #2
0
        public PermissionAttachment AddAttachment(IPlugin plugin)
        {
            PermissionAttachment result = new PermissionAttachment(plugin, this.Parent);

            this.Attachments.Add(result);

            this.RecalculatePermissions();
            return(result);
        }
Exemple #3
0
 public void RemoveAttachment(PermissionAttachment attachment)
 {
     if (this.Attachments.Contains(attachment))
     {
         this.Attachments.Remove(attachment);
         IPermissionRemovedExecutor ex = attachment.Removed;
         if (ex != null)
         {
             ex.AttachmentRemoved(attachment);
         }
         this.RecalculatePermissions();
     }
 }
Exemple #4
0
        public void RecalculatePermissions()
        {
            this.ClearPermissions();
            Dictionary <string, Permission> defaults = new Dictionary <string, Permission>(); //TODO : PluginManager

            //TODO : PluginManager.SubscribeToDefaltPerms();

            foreach (Permission perm in defaults.Values)
            {
                string name = perm.Name;
                this.Permissions[name] = new PermissionAttachmentInfo(this.Parent != null ? this.Parent : this, name, null, true);
                //TODO : PluginManager.SubscribeToDefaltPerms();
                this.CalculateChildPermissions(perm.Children, false, null);
            }

            for (int i = 0; i < this.Attachments.Count; ++i)
            {
                PermissionAttachment attachment = this.Attachments[i];
                this.CalculateChildPermissions(attachment.GetPermissions(), false, attachment);
            }
        }
Exemple #5
0
        private void CalculateChildPermissions(Dictionary <string, bool> children, bool invert, PermissionAttachment attachment)
        {
            foreach (string name in children.Keys)
            {
                Permission perm  = null; //TODO : PluginManager.GetPermission(name);
                bool       value = (children[name] ^ invert);
                this.Permissions[name] = new PermissionAttachmentInfo(this.Parent != null ? this.Parent : this, name, attachment, value);
                //TODO : PluginManager.SubscribeToPermission();

                if (perm != null)
                {
                    this.CalculateChildPermissions(perm.Children, !value, attachment);
                }
            }
        }