NetworkInformationPermission.Union(IPermission) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a permission that is the union of this permission and the specified permission.
public:
override System::Security::IPermission ^ Union(System::Security::IPermission ^ target);
public override System.Security.IPermission Union (System.Security.IPermission target);
override this.Union : System.Security.IPermission -> System.Security.IPermission
Public Overrides Function Union (target As IPermission) As IPermission
Parameters
- target
- IPermission
A NetworkInformationPermission permission to combine with the current permission.
Returns
A new permission that represents the union of the current permission and the specified permission.
Examples
The following example creates a permission object that is the union of existing permission objects.
System::Net::NetworkInformation::NetworkInformationPermission^ unrestricted = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::Unrestricted );
Console::WriteLine( L"Is unrestricted? {0}", unrestricted->IsUnrestricted() );
System::Net::NetworkInformation::NetworkInformationPermission^ read = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read );
System::Net::NetworkInformation::NetworkInformationPermission^ copyPermission = dynamic_cast<System::Net::NetworkInformation::NetworkInformationPermission^>(read->Copy());
System::Net::NetworkInformation::NetworkInformationPermission^ unionPermission = dynamic_cast<System::Net::NetworkInformation::NetworkInformationPermission^>(read->Union( unrestricted ));
Console::WriteLine( L"Is subset?{0}", read->IsSubsetOf( unionPermission ) );
System.Net.NetworkInformation.NetworkInformationPermission unrestricted =
new System.Net.NetworkInformation.NetworkInformationPermission(
System.Security.Permissions.PermissionState.Unrestricted);
Console.WriteLine("Is unrestricted? " + unrestricted.IsUnrestricted());
System.Net.NetworkInformation.NetworkInformationPermission read =
new System.Net.NetworkInformation.NetworkInformationPermission(
System.Net.NetworkInformation.NetworkInformationAccess.Read);
System.Net.NetworkInformation.NetworkInformationPermission copyPermission =
(System.Net.NetworkInformation.NetworkInformationPermission) read.Copy();
System.Net.NetworkInformation.NetworkInformationPermission unionPermission =
(System.Net.NetworkInformation.NetworkInformationPermission) read.Union(unrestricted);
Console.WriteLine("Is subset?" + read.IsSubsetOf(unionPermission));
Dim unrestricted As New System.Net.NetworkInformation.NetworkInformationPermission( _
System.Security.Permissions.PermissionState.Unrestricted)
Console.WriteLine("Is unrestricted? " + unrestricted.IsUnrestricted().ToString())
Dim read As New System.Net.NetworkInformation.NetworkInformationPermission( _
System.Net.NetworkInformation.NetworkInformationAccess.Read)
Dim copyPermission As System.Net.NetworkInformation.NetworkInformationPermission = _
CType(read.Copy(), System.Net.NetworkInformation.NetworkInformationPermission)
Dim unionPermission As System.Net.NetworkInformation.NetworkInformationPermission = _
CType(read.Union(unrestricted), System.Net.NetworkInformation.NetworkInformationPermission)
Console.WriteLine("Is subset?" + read.IsSubsetOf(unionPermission).ToString())
Remarks
The Union method returns a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.