예제 #1
0
        public override IPermission Union(IPermission target)
        {
            StrongNameIdentityPermission snip = Cast(target);

            if ((snip == null) || snip.IsEmpty())
            {
                return(Copy());
            }

            if (IsEmpty())
            {
                return(snip.Copy());
            }

            StrongNameIdentityPermission union = (StrongNameIdentityPermission)Copy();

            foreach (SNIP e in snip._list)
            {
                if (!IsEmpty(e) && !Contains(e))
                {
                    union._list.Add(e);
                }
            }
            return(union);
        }
예제 #2
0
        public override IPermission Intersect(IPermission target)
        {
            StrongNameIdentityPermission snip = (target as StrongNameIdentityPermission);

            if ((snip == null) || IsEmpty())
            {
                return(null);
            }
            if (snip.IsEmpty())
            {
                return(new StrongNameIdentityPermission(PermissionState.None));
            }
            if (!Match(snip.Name))
            {
                return(null);
            }

            string n = ((Name.Length < snip.Name.Length) ? Name : snip.Name);

            if (!Version.Equals(snip.Version))
            {
                return(null);
            }
            if (!PublicKey.Equals(snip.PublicKey))
            {
                return(null);
            }

            return(new StrongNameIdentityPermission(this.PublicKey, n, this.Version));
        }
예제 #3
0
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            StrongNameIdentityPermission snip = (target as StrongNameIdentityPermission);

            if (snip == null)
            {
                throw new ArgumentException(Locale.GetText("Wrong permission type."));
            }
            if (IsEmpty() || snip.IsEmpty())
            {
                return(null);
            }
            if (!Match(snip.Name))
            {
                return(null);
            }

            string n = ((Name.Length < snip.Name.Length) ? Name : snip.Name);

            if (!Version.Equals(snip.Version))
            {
                return(null);
            }
            if (!PublicKey.Equals(snip.PublicKey))
            {
                return(null);
            }

            return(new StrongNameIdentityPermission(this.PublicKey, n, this.Version));
        }
        /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
        /// <returns>A new permission that represents the intersection of the current permission and the specified permission, or null if the intersection is empty.</returns>
        /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission. </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not null and is not of the same type as the current permission. </exception>
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            StrongNameIdentityPermission strongNameIdentityPermission = target as StrongNameIdentityPermission;

            if (strongNameIdentityPermission == null)
            {
                throw new ArgumentException(Locale.GetText("Wrong permission type."));
            }
            if (this.IsEmpty() || strongNameIdentityPermission.IsEmpty())
            {
                return(null);
            }
            if (!this.Match(strongNameIdentityPermission.Name))
            {
                return(null);
            }
            string name = (this.Name.Length >= strongNameIdentityPermission.Name.Length) ? strongNameIdentityPermission.Name : this.Name;

            if (!this.Version.Equals(strongNameIdentityPermission.Version))
            {
                return(null);
            }
            if (!this.PublicKey.Equals(strongNameIdentityPermission.PublicKey))
            {
                return(null);
            }
            return(new StrongNameIdentityPermission(this.PublicKey, name, this.Version));
        }
예제 #5
0
        public override IPermission Union(IPermission target)
        {
            StrongNameIdentityPermission snip = Cast(target);

            if ((snip == null) || snip.IsEmpty())
            {
                return(Copy());
            }

            if (IsEmpty())
            {
                return(snip.Copy());
            }

            if (!PublicKey.Equals(snip.PublicKey))
            {
                return(null);
            }

            string n = Name;

            if ((n == null) || (n.Length == 0))
            {
                n = snip.Name;
            }
            else if (Match(snip.Name))
            {
                n = ((Name.Length > snip.Name.Length) ? Name : snip.Name);
            }
            else if ((snip.Name != null) && (snip.Name.Length > 0) && (n != snip.Name))
            {
                return(null);
            }

            Version v = Version;

            if (v == null)
            {
                v = snip.Version;
            }
            else if ((snip.Version != null) && (v != snip.Version))
            {
                return(null);
            }

            return(new StrongNameIdentityPermission(PublicKey, n, v));
        }
        /// <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">The <paramref name="target" /> parameter is not null and is not of the same type as the current permission. -or-The two permissions are not equal and one is a subset of the other.</exception>
        public override IPermission Union(IPermission target)
        {
            StrongNameIdentityPermission strongNameIdentityPermission = this.Cast(target);

            if (strongNameIdentityPermission == null || strongNameIdentityPermission.IsEmpty())
            {
                return(this.Copy());
            }
            if (this.IsEmpty())
            {
                return(strongNameIdentityPermission.Copy());
            }
            StrongNameIdentityPermission strongNameIdentityPermission2 = (StrongNameIdentityPermission)this.Copy();

            foreach (object obj in strongNameIdentityPermission._list)
            {
                StrongNameIdentityPermission.SNIP snip = (StrongNameIdentityPermission.SNIP)obj;
                if (!this.IsEmpty(snip) && !this.Contains(snip))
                {
                    strongNameIdentityPermission2._list.Add(snip);
                }
            }
            return(strongNameIdentityPermission2);
        }