UrlIdentityPermission.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 url1 As String
Dim urlIdPerm1, urlIdPerm2 As UrlIdentityPermission
Dim urlGen1 As New UrlGenerator()
Dim urlGen2 As New UrlGenerator()
urlGen1.ResetIndex()
While urlGen1.CreateUrl(urlIdPerm1, url1)
If urlIdPerm1 Is Nothing Then
GoTo ContinueWhile1
End If
urlGen2.ResetIndex()
Console.WriteLine("********************************************************\n")
Try
urlIdPerm2 = CType(urlIdPerm1.Copy(), UrlIdentityPermission)
If Not (urlIdPerm2 Is Nothing) Then
Console.WriteLine("Result of copy = " & urlIdPerm2.ToString() & ControlChars.Lf)
Else
Console.WriteLine("Result of copy is null. " & ControlChars.Lf)
End If
Catch e As Exception
If (True.ToString()) Then
If url1 = "" Then
Console.WriteLine("The target UrlIdentityPermission 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 url1;
UrlIdentityPermission urlIdPerm1,urlIdPerm2;
UrlGenerator urlGen1 = new UrlGenerator();
UrlGenerator urlGen2 = new UrlGenerator();
urlGen1.ResetIndex();
while(urlGen1.CreateUrl(out urlIdPerm1, out url1))
{
if(urlIdPerm1 == null ) continue;
urlGen2.ResetIndex();
Console.WriteLine("********************************************************\n");
try
{
urlIdPerm2 = (UrlIdentityPermission)urlIdPerm1.Copy();
if (urlIdPerm2 != null)
{
Console.WriteLine("Result of copy = " + urlIdPerm2.ToString() + "\n");
}
else
{
Console.WriteLine("Result of copy is null. \n");
}
}
catch(Exception e)
{
{
if (url1 == "")
{
Console.WriteLine( "The target UrlIdentityPermission 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* url1;
UrlIdentityPermission* urlIdPerm1, *urlIdPerm2;
UrlGenerator* urlGen1 = new UrlGenerator();
UrlGenerator* urlGen2 = new UrlGenerator();
urlGen1->ResetIndex();
while(urlGen1->CreateUrl(&urlIdPerm1, &url1)) {
if (urlIdPerm1 == 0) continue;
urlGen2->ResetIndex();
Console::WriteLine(S"********************************************************\n");
try {
urlIdPerm2 = dynamic_cast<UrlIdentityPermission*>(urlIdPerm1->Copy());
if (urlIdPerm2 != 0) {
Console::WriteLine(S"Result of copy = {0}\n", urlIdPerm2);
} else {
Console::WriteLine(S"Result of copy is null. \n");
}
} catch (Exception* e) { {
if (url1->Equals(S"")) {
Console::WriteLine(S"The target UrlIdentityPermission 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 ファミリ
参照
UrlIdentityPermission クラス | UrlIdentityPermission メンバ | System.Security.Permissions 名前空間