/// <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); } }
public PermissionInfoCollection GetGrandedPermission() { PermissionInfoCollection collection = new PermissionInfoCollection(); collection.Add(new DefaultPermissionInfo("name1", "action1")); collection.Add(new DefaultPermissionInfo("name2", "action2")); return(collection); }
/// <summary> /// 深度克隆 /// </summary> public object Clone() { PermissionInfoCollection clone = new PermissionInfoCollection(); foreach (PermissionInfo per in permissions) { clone.Add((PermissionInfo)per.Clone()); } return(clone); }
private bool EqualsInOther(PermissionInfo per, PermissionInfoCollection collection) { foreach (PermissionInfo p in collection) { if (p.Equals(per)) { return(true); } } return(false); }