Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)
'Declaration
Public Overrides Function Intersect ( _
	target As IPermission _
) As IPermission

Parameters

target
Type: System.Security.IPermission

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

Return Value

Type: System.Security.IPermission
A new permission that represents the intersection of the current permission and the specified permission, or Nothing if the intersection is empty.

Implements

IPermission.Intersect(IPermission)
ExceptionCondition
ArgumentException

The target parameter is not Nothing 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.

NoteNote

The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.

' Intersect creates and returns a new permission that is the intersection of the current 
' permission and the permission specified. 
Private Function IntersectDemo() As Boolean  

    Dim returnValue As Boolean = True 

    Dim snIdPerm1, snIdPerm2, snIdPerm3 As StrongNameIdentityPermission

    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 = CType(snIdPerm1.Intersect(snIdPerm2), StrongNameIdentityPermission)

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

    Catch e As Exception
        Console.WriteLine("An exception was thrown: " + e.ToString())
        returnValue = False 
    End Try 

    Return returnValue

End Function 'IntersectDemo
 

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.