コード例 #1
0
        /// <summary>
        /// Adds <see cref="Permission"/> to the <see cref="credential"/> with
        /// the specified <see cref="Privilege"/>.
        /// </summary>
        /// <param name="credential"></param>
        /// <param name="privilege"></param>
        /// <see cref="CredentialBase.AddRole(Feature,Privilege?)"/>
        protected internal virtual void AddRole(CredentialBase credential, Privilege?privilege = null)
        {
            privilege = privilege ?? Inherited;

            //Will assume that the Credential Roles already contains him.
            var p = Permissions.SingleOrDefault(r => r.Feature.Equals(this) && r.Credential.Equals(credential));

            if (p != null)
            {
                //Touch the privilege on the way out.
                p.Privilege = privilege;
                return;
            }

            InternalPermissions.Add(new Permission
            {
                Credential = credential,
                Privilege  = privilege
            });
        }
コード例 #2
0
        /// <summary>
        /// Removes the role associated with this Feature and the
        /// <see cref="CredentialBase"/> if it exists.
        /// </summary>
        /// <param name="credential"></param>
        /// <returns></returns>
        public virtual bool RemoveRole(CredentialBase credential)
        {
            var p = Permissions.SingleOrDefault(r => r.Feature.Equals(this) && r.Credential.Equals(credential));

            return(p != null && InternalPermissions.Remove(p));
        }