StrongNameIdentityPermission.Copy メソッド
現在のアクセス許可のコピーを作成して返します。
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 Sn1 As String
Dim SnIdPerm1, SnIdPerm2 As StrongNameIdentityPermission
Dim SnGen1 As New SnGenerator()
Dim SnGen2 As New SnGenerator()
SnGen1.ResetIndex()
While SnGen1.CreateSn(SnIdPerm1, Sn1)
If SnIdPerm1 Is Nothing Then
GoTo ContinueWhile1
End If
SnGen2.ResetIndex()
Console.WriteLine("********************************************************" + ControlChars.Lf)
Try
SnIdPerm2 = CType(SnIdPerm1.Copy(), StrongNameIdentityPermission)
If Not (SnIdPerm2 Is Nothing) Then
Console.WriteLine(("Result of copy = " + SnIdPerm2.ToString() + ControlChars.Lf))
Else
Console.WriteLine("Result of copy is null. " + ControlChars.Lf)
End If
Catch e As Exception
If (True.ToString()) Then
If Sn1 = "" Then
Console.WriteLine("The target StrongNameIdentityPermission 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 sn1;
StrongNameIdentityPermission snIdPerm1,snIdPerm2;
SnGenerator snGen1 = new SnGenerator();
SnGenerator snGen2 = new SnGenerator();
snGen1.ResetIndex();
while(snGen1.CreateSn(out snIdPerm1, out sn1))
{
if(snIdPerm1 == null ) continue;
snGen2.ResetIndex();
Console.WriteLine("********************************************************");
try
{
snIdPerm2 = (StrongNameIdentityPermission)snIdPerm1.Copy();
if (snIdPerm2 != null)
{
Console.WriteLine("Result of copy = " + snIdPerm2.ToString() + "\n");
}
else
{
Console.WriteLine("Result of copy is null. \n");
}
}
catch(Exception e)
{
{
if (sn1 == "")
{
Console.WriteLine( "The target StrongNameIdentityPermission is empty; copy failed.");
}
else
Console.WriteLine( e);
}
continue;
}
}
return returnValue;
}
[C++]
//Copy creates and returns an identical copy of the current permission.
bool CopyDemo() {
bool returnValue = true;
String* sn1;
StrongNameIdentityPermission* snIdPerm1, *snIdPerm2;
SnGenerator* snGen1 = new SnGenerator();
SnGenerator* snGen2 = new SnGenerator();
snGen1->ResetIndex();
while(snGen1->CreateSn(&snIdPerm1, &sn1)) {
if (snIdPerm1 == 0) continue;
snGen2->ResetIndex();
Console::WriteLine(S"********************************************************");
try {
snIdPerm2 = dynamic_cast<StrongNameIdentityPermission*>(snIdPerm1->Copy());
if (snIdPerm2 != 0) {
Console::WriteLine(S"Result of copy = {0}\n", snIdPerm2);
} else {
Console::WriteLine(S"Result of copy is null.\n");
}
} catch (Exception* e) { {
if (sn1->Equals(S"")) {
Console::WriteLine(S"The target StrongNameIdentityPermission 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 ファミリ
参照
StrongNameIdentityPermission クラス | StrongNameIdentityPermission メンバ | System.Security.Permissions 名前空間