NetworkInformationPermission.Intersect(IPermission) メソッド

定義

現在のアクセス許可と指定したアクセス許可の積集合となるアクセス許可を作成して返します。

public:
 override System::Security::IPermission ^ Intersect(System::Security::IPermission ^ target);
public override System.Security.IPermission Intersect (System.Security.IPermission target);
override this.Intersect : System.Security.IPermission -> System.Security.IPermission
Public Overrides Function Intersect (target As IPermission) As IPermission

パラメーター

target
IPermission

現在のアクセス許可との積集合を持つ IPermission。 これは、現在のアクセス許可と同じ型であることが必要です。

戻り値

現在のアクセス許可と指定したアクセス許可の積集合を表す NetworkInformationPermission。 積集合が空か targetnull の場合、この新しいアクセス許可は null です。

例外

targetNetworkInformationPermission ではありません。

次の例では、既存のアクセス許可オブジェクトの共通部分であるアクセス許可オブジェクトを作成します。

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^ intersectPermission = dynamic_cast<System::Net::NetworkInformation::NetworkInformationPermission^>(read->Intersect( unrestricted ));
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));
System.Net.NetworkInformation.NetworkInformationPermission intersectPermission =
   (System.Net.NetworkInformation.NetworkInformationPermission) read.Intersect(unrestricted);
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())
Dim intersectPermission As System.Net.NetworkInformation.NetworkInformationPermission = _ 
    CType(read.Intersect(unrestricted), _ 
          System.Net.NetworkInformation.NetworkInformationPermission)

注釈

2 つのアクセス許可の共通部分は、両者が共通して記述する状態を記述するアクセス許可です。 両方の元のアクセス許可を渡す要求のみが交差を通過します。

適用対象