IPermission.Union(IPermission) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在のアクセス許可と指定されたアクセス許可の和集合であるアクセス許可を作成します。
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 である必要があります。 XではないY``nullオブジェクトを表IPermissionします。
X.Union(X) は、次と同じ値Xを持つオブジェクトを返します。X.Union(Y) は、返されるオブジェクトと同じ値を持つオブジェクトを返Yします。Union(X).X.Union(null) は、次と同じ値Xを持つオブジェクトを返します。