System.Net.DnsPermission.Intersect C# (CSharp) Method

Intersect() public method

public Intersect ( IPermission target ) : IPermission
target IPermission
return IPermission
        public override IPermission Intersect(IPermission target) {
            // Pattern suggested by Security engine
            if (target==null) {
                return null;
            }
            DnsPermission other = target as DnsPermission;
            if(other == null) {
                throw new ArgumentException(SR.GetString(SR.net_perm_target), "target");
            }

            // return null if resulting permission is restricted and empty
            // Hence, the only way for a bool permission will be.
            if (this.m_noRestriction && other.m_noRestriction) {
                return new DnsPermission(true);
            }
            return null;
        }

Usage Example

		public void Intersect ()
		{
			DnsPermission dpn = new DnsPermission (PermissionState.None);
			Assert.IsNull (dpn.Intersect (null), "None N null");
			Assert.IsNull (dpn.Intersect (dpn), "None N None");

			DnsPermission dpu = new DnsPermission (PermissionState.Unrestricted);
			Assert.IsNull (dpu.Intersect (null), "Unrestricted N null");

			DnsPermission result = (DnsPermission) dpu.Intersect (dpu);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted N Unrestricted");

			Assert.IsNull (dpn.Intersect (dpu), "None N Unrestricted");
			Assert.IsNull (dpu.Intersect (dpn), "Unrestricted N None");
		}
All Usage Examples Of System.Net.DnsPermission::Intersect