예제 #1
0
        /// <summary>
        /// 性能较低。通常权限集不进行相等比较
        /// </summary>
        public override bool Equals(object other)
        {
            if (other == this)
            {
                return(true);
            }
            PermissionInfoCollection c = other as PermissionInfoCollection;

            if (c == null)
            {
                return(false);
            }
            if (this.Count != c.Count)
            {
                return(false);
            }
            for (int i = 0; i < this.Count; i++)
            {
                if (!EqualsInOther(this[i], c))
                {
                    return(false);
                }
            }
            if (electVisitor != null)
            {
                return(electVisitor.Equals(c.electVisitor));
            }
            else
            {
                return(c.electVisitor == null);
            }
        }
예제 #2
0
        public PermissionInfoCollection GetGrandedPermission()
        {
            PermissionInfoCollection collection = new PermissionInfoCollection();

            collection.Add(new DefaultPermissionInfo("name1", "action1"));
            collection.Add(new DefaultPermissionInfo("name2", "action2"));
            return(collection);
        }
예제 #3
0
        /// <summary>
        /// 深度克隆
        /// </summary>
        public object Clone()
        {
            PermissionInfoCollection clone = new PermissionInfoCollection();

            foreach (PermissionInfo per in permissions)
            {
                clone.Add((PermissionInfo)per.Clone());
            }
            return(clone);
        }
예제 #4
0
 private bool EqualsInOther(PermissionInfo per, PermissionInfoCollection collection)
 {
     foreach (PermissionInfo p in collection)
     {
         if (p.Equals(per))
         {
             return(true);
         }
     }
     return(false);
 }