public CopyTo ( |
||
array | ||
index | int | |
리턴 | void |
public override IPermission Union(IPermission target) { KeyContainerPermission kcp = Cast(target); if (kcp == null) { return(Copy()); } KeyContainerPermissionAccessEntryCollection kcpaec = new KeyContainerPermissionAccessEntryCollection(); // copy first group foreach (KeyContainerPermissionAccessEntry kcpae in _accessEntries) { kcpaec.Add(kcpae); } // copy second group... foreach (KeyContainerPermissionAccessEntry kcpae in kcp._accessEntries) { // ... but only if not present in first group if (_accessEntries.IndexOf(kcpae) == -1) { kcpaec.Add(kcpae); } } if (kcpaec.Count == 0) { return(new KeyContainerPermission((_flags | kcp._flags))); } KeyContainerPermissionAccessEntry[] list = new KeyContainerPermissionAccessEntry [kcpaec.Count]; kcpaec.CopyTo(list, 0); return(new KeyContainerPermission((_flags | kcp._flags), list)); }
/// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary> /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns> /// <param name="target">A permission to combine with the current permission. It must be of the same type as the current permission. </param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="target" /> is not null and does not specify a permission of the same type as the current permission. </exception> public override IPermission Union(IPermission target) { KeyContainerPermission keyContainerPermission = this.Cast(target); if (keyContainerPermission == null) { return(this.Copy()); } KeyContainerPermissionAccessEntryCollection keyContainerPermissionAccessEntryCollection = new KeyContainerPermissionAccessEntryCollection(); foreach (KeyContainerPermissionAccessEntry accessEntry in this._accessEntries) { keyContainerPermissionAccessEntryCollection.Add(accessEntry); } foreach (KeyContainerPermissionAccessEntry accessEntry2 in keyContainerPermission._accessEntries) { if (this._accessEntries.IndexOf(accessEntry2) == -1) { keyContainerPermissionAccessEntryCollection.Add(accessEntry2); } } if (keyContainerPermissionAccessEntryCollection.Count == 0) { return(new KeyContainerPermission(this._flags | keyContainerPermission._flags)); } KeyContainerPermissionAccessEntry[] array = new KeyContainerPermissionAccessEntry[keyContainerPermissionAccessEntryCollection.Count]; keyContainerPermissionAccessEntryCollection.CopyTo(array, 0); return(new KeyContainerPermission(this._flags | keyContainerPermission._flags, array)); }
// Methods public override IPermission Copy() { if (_accessEntries.Count == 0) { return(new KeyContainerPermission(_flags)); } KeyContainerPermissionAccessEntry[] list = new KeyContainerPermissionAccessEntry [_accessEntries.Count]; _accessEntries.CopyTo(list, 0); return(new KeyContainerPermission(_flags, list)); }
public override IPermission Union (IPermission target) { KeyContainerPermission kcp = Cast (target); if (kcp == null) return Copy (); KeyContainerPermissionAccessEntryCollection kcpaec = new KeyContainerPermissionAccessEntryCollection (); // copy first group foreach (KeyContainerPermissionAccessEntry kcpae in _accessEntries) { kcpaec.Add (kcpae); } // copy second group... foreach (KeyContainerPermissionAccessEntry kcpae in kcp._accessEntries) { // ... but only if not present in first group if (_accessEntries.IndexOf (kcpae) == -1) kcpaec.Add (kcpae); } if (kcpaec.Count == 0) return new KeyContainerPermission ((_flags | kcp._flags)); KeyContainerPermissionAccessEntry[] list = new KeyContainerPermissionAccessEntry [kcpaec.Count]; kcpaec.CopyTo (list, 0); return new KeyContainerPermission ((_flags | kcp._flags), list); }