アクセス許可とその現在の状態を表す XML エンコーディングを作成します。
Overrides Public Function ToXml() As SecurityElement Implements _ ISecurityEncodable.ToXml
[C#]
public override SecurityElement ToXml();
[C++]
public: SecurityElement* ToXml();
[JScript]
public override function ToXml() : SecurityElement;
戻り値
状態情報を含む、アクセス許可の XML エンコーディング。
実装
使用例
' ToXml creates an XML encoding of the permission and its current state; FromXml
' reconstructs a permission with the specified state from the XML encoding.
Private Function ToFromXmlDemo() As Boolean
Dim retCode As Boolean = True
Dim publisher1 As [String]
Dim pubIdPerm1, pubIdPerm2 As PublisherIdentityPermission
Dim pubGen1 As New PublisherGenerator()
Dim pubGen2 As New PublisherGenerator()
pubGen1.ResetIndex()
While pubGen1.CreatePublisher(pubIdPerm1, publisher1)
If pubIdPerm1 Is Nothing Then
GoTo ContinueWhile1
End If
pubGen2.ResetIndex()
Try
pubIdPerm2 = New PublisherIdentityPermission(PermissionState.None)
pubIdPerm2.FromXml(pubIdPerm1.ToXml())
Console.WriteLine(("Result of ToFromXml = " & pubIdPerm2.ToString() & ControlChars.Lf))
Catch e As Exception
Console.WriteLine(("ToFromXml failed :" & pubIdPerm1.ToString() & e.ToString()))
GoTo ContinueWhile1
End Try
ContinueWhile1:
End While
Return retCode
End Function 'ToFromXmlDemo
[C#]
// ToXml creates an XML encoding of the permission and its current state; FromXml
// reconstructs a permission with the specified state from the XML encoding.
private bool ToFromXmlDemo()
{
bool retCode = true;
String publisher1;
PublisherIdentityPermission pubIdPerm1,pubIdPerm2;
PublisherGenerator pubGen1 = new PublisherGenerator();
PublisherGenerator pubGen2 = new PublisherGenerator();
pubGen1.ResetIndex();
while(pubGen1.CreatePublisher(out pubIdPerm1, out publisher1))
{
if(pubIdPerm1 == null) continue;
pubGen2.ResetIndex();
try
{
pubIdPerm2= new PublisherIdentityPermission(PermissionState.None);
pubIdPerm2.FromXml(pubIdPerm1.ToXml());
Console.WriteLine("Result of ToFromXml = " +pubIdPerm2.ToString() + "\n");
}
catch(Exception e)
{
Console.WriteLine("ToFromXml failed :" + pubIdPerm1.ToString() + e);
continue;
}
}
return retCode;
}
[C++]
// ToXml creates an XML encoding of the permission and its current state; FromXml
// reconstructs a permission with the specified state from the XML encoding.
bool ToFromXmlDemo()
{
bool retCode = true;
String* publisher1;
PublisherIdentityPermission* pubIdPerm1;
PublisherIdentityPermission* pubIdPerm2;
PublisherGenerator* pubGen1 = new PublisherGenerator();
PublisherGenerator* pubGen2 = new PublisherGenerator();
pubGen1->ResetIndex();
while(pubGen1->CreatePublisher(&pubIdPerm1, &publisher1))
{
if(pubIdPerm1 == 0) continue;
pubGen2->ResetIndex();
try
{
pubIdPerm2= new PublisherIdentityPermission(PermissionState::None);
pubIdPerm2->FromXml(pubIdPerm1->ToXml());
Console::WriteLine(S"Result of ToFromXml = {0}\n", pubIdPerm2);
}
catch(Exception* e)
{
Console::WriteLine(S"ToFromXml failed :{0}{1}", pubIdPerm1, e);
continue;
}
}
return retCode;
}
[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 ファミリ
参照
PublisherIdentityPermission クラス | PublisherIdentityPermission メンバ | System.Security.Permissions 名前空間