Share via


IPermission.Union(IPermission) 메서드

정의

현재 사용 권한 및 지정한 사용 권한을 합한 사용 권한을 만듭니다.

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

매개 변수

target
IPermission

현재 사용 권한과 결합할 사용 권한입니다. 현재 사용 권한과 동일한 형식이어야 합니다.

반환

현재 사용 권한 및 지정한 사용 권한의 합을 나타내는 새 사용 권한입니다.

예외

target 매개 변수가 null이 아니고 현재 사용 권한과 형식이 다른 경우

예제

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

    // Return a new object that contains the union of 'this' and 'target'.
    // Note: You do not have to implement this method. 
    // If you do not, the version
    // in CodeAccessPermission does this:
    //    1. If target is not null, a NotSupportedException is thrown.
    //    2. If target is null, then Copy is called and 
    //       the new object is returned.
public:
    virtual IPermission^ Union(IPermission^ target) override
    {
        // If 'target' is null, then return a copy of 'this'.
        if (target == nullptr)
        {
            return Copy();
        }

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

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

        // Return a new object with the calculated, unioned permission value.
        return Clone(false, (SoundPermissionState)
            Math::Max((int) stateFlags, (int) soundPerm->stateFlags));
    }
// Return a new object that contains the union of 'this' and 'target'.
// Note: You do not have to implement this method. If you do not, the version
// in CodeAccessPermission does this:
//    1. If target is not null, a NotSupportedException is thrown.
//    2. If target is null, then Copy is called and the new object is returned.
public override IPermission Union(IPermission target)
{
    // If 'target' is null, then return a copy of 'this'.
    if (target == null) return Copy();

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

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

    // Return a new object with the calculated, unioned permission value.
    return Clone(false, (SoundPermissionState)
        Math.Max((Int32)m_flags, (Int32)soundPerm.m_flags));
}
' Return a new object that contains the union of 'this' and 'target'.
' Note: You do not have to implement this method. If you do not, the version
' in CodeAccessPermission does this:
'    1. If target is not null, a NotSupportedException is thrown.
'    2. If target is null, then Copy is called and the new object is returned.
Public Overrides Function Union(ByVal target As IPermission) As IPermission
    ' If 'target' is null, then return a copy of 'this'.
    If target Is Nothing Then
        Return Copy()
    End If
    ' Both objects must be the same type.
    Dim soundPerm As SoundPermission = VerifyTypeMatch(target)

    ' If 'this' or 'target' are unrestricted, return a new unrestricted permission.
    If m_specifiedAsUnrestricted OrElse soundPerm.m_specifiedAsUnrestricted Then
        Return Clone(True, SoundPermissionState.PlayAnySound)
    End If
    ' Return a new object with the calculated, unioned permission value.
    Return Clone(False, CType(Math.Max(CType(m_flags, Int32), CType(soundPerm.m_flags, Int32)), SoundPermissionState))

End Function 'Union

설명

에 대한 호출 Union 의 결과는 현재 권한과 지정된 권한 모두에 의해 표시되는 모든 작업을 나타내는 권한입니다. 두 권한 중 하나를 통과하는 모든 요구는 해당 공용 구조체를 통과합니다.

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

  • X. Union(X)은 와 같은 값을 X가지는 개체를 반환합니다.

  • X. Union(Y)은 에서 반환하는 개체와 동일한 값을 가지는 개체를 반환 Y합니다. Union(X).

  • X. Union(null)은 와 같은 값을 X가지는 개체를 반환합니다.

적용 대상