Share via


IPermission.Intersect(IPermission) 메서드

정의

현재 사용 권한 및 지정된 사용 권한의 공통 권한을 만들어 반환합니다.

public:
 System::Security::IPermission ^ Intersect(System::Security::IPermission ^ target);
public System.Security.IPermission Intersect (System.Security.IPermission target);
public System.Security.IPermission? Intersect (System.Security.IPermission? target);
abstract member Intersect : System.Security.IPermission -> System.Security.IPermission
Public Function Intersect (target As IPermission) As IPermission

매개 변수

target
IPermission

현재 사용 권한과 공통되는 사용 권한입니다. 현재 사용 권한과 동일한 형식이어야 합니다.

반환

현재 사용 권한과 지정된 사용 권한의 교집합에 해당하는 권한을 나타내는 새 사용 권한입니다. 교집합이 비어 있으면 새 사용 권한은 null입니다.

예외

target 매개 변수가 null이 아니고 현재 사용 권한과 동일한 클래스의 인스턴스가 아닌 경우

예제

다음 코드 예제에서는 구현 하는 방법을 보여 줍니다는 Intersect 메서드. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 IPermission 클래스입니다.

    // Return a new object that contains the intersection 
    // of 'this' and 'target'.
public:
    virtual IPermission^ Intersect(IPermission^ target) override
    {
        // If 'target' is null, return null.
        if (target == nullptr)
        {
            return nullptr;
        }

        // Both objects must be the same type.
        SoundPermission^ soundPerm = VerifyTypeMatch(target);

        // If 'this' and 'target' are unrestricted, 
        // return a new unrestricted permission.
        if (specifiedAsUnrestricted && soundPerm->specifiedAsUnrestricted)
        {
            return Clone(true, SoundPermissionState::PlayAnySound);
        }

        // Calculate the intersected permissions. 
        // If there are none, return null.
        SoundPermissionState minimumPermission = (SoundPermissionState)
            Math::Min((int) stateFlags, (int) soundPerm->stateFlags);
        if ((int)minimumPermission == 0)
        {
            return nullptr;
        }

        // Return a new object with the intersected permission value.
        return Clone(false, minimumPermission);
    }
// Return a new object that contains the intersection of 'this' and 'target'.
public override IPermission Intersect(IPermission target)
{
    // If 'target' is null, return null.
    if (target == null) return null;

    // Both objects must be the same type.
    SoundPermission soundPerm = VerifyTypeMatch(target);

    // If 'this' and 'target' are unrestricted, return a new unrestricted permission.
    if (m_specifiedAsUnrestricted && soundPerm.m_specifiedAsUnrestricted)
        return Clone(true, SoundPermissionState.PlayAnySound);

    // Calculate the intersected permissions. If there are none, return null.
    SoundPermissionState val = (SoundPermissionState)
        Math.Min((Int32)m_flags, (Int32)soundPerm.m_flags);
    if (val == 0) return null;

    // Return a new object with the intersected permission value.
    return Clone(false, val);
}
' Return a new object that contains the intersection of 'this' and 'target'.
Public Overrides Function Intersect(ByVal target As IPermission) As IPermission
    ' If 'target' is null, return null.
    If target Is Nothing Then
        Return Nothing
    End If
    ' Both objects must be the same type.
    Dim soundPerm As SoundPermission = VerifyTypeMatch(target)

    ' If 'this' and 'target' are unrestricted, return a new unrestricted permission.
    If m_specifiedAsUnrestricted AndAlso soundPerm.m_specifiedAsUnrestricted Then
        Return Clone(True, SoundPermissionState.PlayAnySound)
    End If
    ' Calculate the intersected permissions. If there are none, return null.
    Dim val As SoundPermissionState = CType(Math.Min(CType(m_flags, Int32), CType(soundPerm.m_flags, Int32)), SoundPermissionState)
    If val = 0 Then
        Return Nothing
    End If
    ' Return a new object with the intersected permission value.
    Return Clone(False, val)

End Function 'Intersect

설명

두 권한의 교차점은 둘 다 공통적으로 설명하는 작업 집합을 설명하는 권한입니다. 두 원래 사용 권한을 모두 전달하는 요청만 교집합을 통과합니다.

다음 문은 메서드의 Intersect 모든 구현에 대해 true여야 합니다. XY 는 가 아닌 null개체 참조를 나타냅니다IPermission.

  • X. Intersect(X)는 와 같은 값을 반환합니다 X.

  • X. Intersect(Y)는 와 동일한 값을 Y반환합니다. Intersect(X).

  • X. Intersect()는null 를 반환합니다 null.

적용 대상