public void AddAccessRule(SharedObjectAccessRule rule)
 {
     // Check if a rule for the provided security identifier is already in this list...in which an exception is thrown
     if (this.Rules.Where(r => r.IdentityReference == rule.IdentityReference).SingleOrDefault() != null)
     {
         throw new ArgumentException("AccessRule already exists for the provided identity");
     }
     this.Rules.Add(rule);
 }
        /// <summary>
        /// Set security rule for the provided identity, replaces any existing rule
        /// </summary>
        /// <param name="rule"></param>
        public void SetAccessRule(SharedObjectAccessRule rule)
        {
            var oldRule = this.Rules.Where(r => r.IdentityReference == rule.IdentityReference).SingleOrDefault();

            if (oldRule != null)
            {
                this.Rules.Remove(oldRule);
            }
            this.Rules.Add(rule);
        }
Esempio n. 3
0
        public override bool Equals(object obj)
        {
            SharedObjectAccessRule other = obj as SharedObjectAccessRule;

            if (other == null)
            {
                return(false);
            }

            if (this.IdentityReference != other.IdentityReference ||
                this.AccessMask != other.AccessMask ||
                this.IsInherited != other.IsInherited ||
                this.InheritanceFlags != other.InheritanceFlags ||
                this.AccessControlType != other.AccessControlType)
            {
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Returns true if rule was found and removed, else false
 /// </summary>
 /// <param name="rule"></param>
 /// <returns></returns>
 public bool RemoveAccessRule(SharedObjectAccessRule rule)
 {
     return(this.Rules.Remove(rule));
 }