現在のアクセス許可のコピーを作成して返します。
Overrides Public Function Copy() As IPermission Implements _ IPermission.Copy
[C#]
public override IPermission Copy();
[C++]
public: IPermission* Copy();
[JScript]
public override function Copy() : IPermission;
戻り値
現在のアクセス許可のコピー。
実装
解説
アクセス許可のコピーは、リソースに対して、コピー元のアクセス許可と同じアクセス権を表します。
使用例
'Copy creates and returns an identical copy of the current permission.
Private Function CopyDemo() As Boolean
Dim returnValue As Boolean = True
Dim env1 As String
Dim envPerm1, envPerm2 As EnvironmentPermission
Dim envGen1 As New EnvGenerator()
Dim envGen2 As New EnvGenerator()
envGen1.ResetIndex()
While envGen1.CreateEnv(envPerm1, env1, EnvironmentPermissionAccess.Read)
If env1 Is Nothing Then
GoTo ContinueWhile1
End If
Console.WriteLine("**********************************************************" & ControlChars.Lf)
envGen2.ResetIndex()
Try
envPerm2 = CType(envPerm1.Copy(), EnvironmentPermission)
If Not (envPerm2 Is Nothing) Then
Console.WriteLine(("Result of copy = " & envPerm2.ToString() & ControlChars.Lf))
Else
Console.WriteLine("Result of copy is null. " & ControlChars.Lf)
End If
Catch e As Exception
If (True.ToString()) Then
If env1 = "" Then
Console.WriteLine("The EnvironmentPermission is empty, copy failed.")
Else
Console.WriteLine(e.ToString())
End If
End If
GoTo ContinueWhile1
End Try
ContinueWhile1:
End While
Return returnValue
End Function 'CopyDemo
[C#]
//Copy creates and returns an identical copy of the current permission.
private bool CopyDemo()
{
bool returnValue = true;
string env1;
EnvironmentPermission envPerm1,envPerm2;
EnvGenerator envGen1 = new EnvGenerator();
EnvGenerator envGen2 = new EnvGenerator();
envGen1.ResetIndex();
while(envGen1.CreateEnv(out envPerm1, out env1, EnvironmentPermissionAccess.Read))
{
if(env1 == null ) continue;
Console.WriteLine("**********************************************************\n");
envGen2.ResetIndex();
try
{
envPerm2 = (EnvironmentPermission)envPerm1.Copy();
if (envPerm2 != null)
{
Console.WriteLine("Result of copy = " + envPerm2.ToString() + "\n");
}
else
{
Console.WriteLine("Result of copy is null. \n");
}
}
catch(Exception e)
{
{
if (env1 == "")
{
Console.WriteLine( "The EnvironmentPermission is empty, copy failed.");
}
else
Console.WriteLine( e);
}
continue;
}
}
return returnValue;
}
[C++]
//Copy creates and returns an identical copy of the current permission.
private:
bool CopyDemo() {
bool returnValue = true;
String* env1;
EnvironmentPermission* envPerm1, *envPerm2;
EnvGenerator* envGen1 = new EnvGenerator();
EnvGenerator* envGen2 = new EnvGenerator();
envGen1->ResetIndex();
while(envGen1->CreateEnv(&envPerm1, &env1, EnvironmentPermissionAccess::Read)) {
if (env1 == 0) continue;
Console::WriteLine(S"**********************************************************\n");
envGen2->ResetIndex();
try {
envPerm2 = dynamic_cast<EnvironmentPermission*>(envPerm1->Copy());
if (envPerm2 != 0) {
Console::WriteLine(S"Result of copy = {0}\n", envPerm2);
} else {
Console::WriteLine(S"Result of copy is null. \n");
}
} catch (Exception* e) { {
if (env1->Equals(S"")) {
Console::WriteLine(S"The EnvironmentPermission is empty, copy failed.");
} else
Console::WriteLine(e);
}
continue;
}
}
return returnValue;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard
参照
EnvironmentPermission クラス | EnvironmentPermission メンバ | System.Security.Permissions 名前空間