Export (0) Print
Expand All

StrongNameIdentityPermission.Intersect Method

Creates and returns a permission that is the intersection of the current permission and the specified permission.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

public override IPermission Intersect (
	IPermission target
)
public IPermission Intersect (
	IPermission target
)
public override function Intersect (
	target : IPermission
) : IPermission

Parameters

target

A permission to intersect with the current permission. It must be of the same type as the current permission.

Return Value

A new permission that represents the intersection of the current permission and the specified permission, or a null reference (Nothing in Visual Basic) if the intersection is empty.

Exception typeCondition

ArgumentException

The target parameter is not a null reference (Nothing in Visual Basic) and is not of the same type as the current permission.

The intersection of two permissions is a permission that describes the set of operations they both describe in common. Only a demand that passes both original permissions will pass the intersection.

The intersection of two identical strong name identity permissions is the same permission. The intersection of two different (not wildcard) expressions is an empty permission. The intersection of a wildcard expression and a matching strong name is the strong name. The intersection of two wildcard expressions that match is the longer, more specific of the two expressions.

The following code example shows the results of the use of the Intersect method, not how to use the method. This example is part of a larger example provided for the StrongNameIdentityPermission class. The best use for this example is to build and execute the entire example, and view its output.

// Intersect creates and returns a new permission that is the intersection of the current
// permission and the permission specified.
private bool IntersectDemo()
{

    bool returnValue = true;

    StrongNameIdentityPermission snIdPerm1, snIdPerm2, snIdPerm3;

    snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
    snIdPerm2 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", new Version("1.0.0.0"));

    try
    {

        snIdPerm3 = (StrongNameIdentityPermission)snIdPerm1.Intersect(snIdPerm2);

        Console.WriteLine("The intersection of MyCompany.MyDepartment.*"
        + "MyCompany.MyDepartment.MyFile is "
        + ((StrongNameIdentityPermission)snIdPerm3).Name.ToString());

    }
    catch (Exception e)
    {
        Console.WriteLine("An exception was thrown: " + e);
        returnValue = false;
    }

    return returnValue;

}

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft