GacMembershipCondition.ToXml Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Membuat pengodean XML objek keamanan dan statusnya saat ini.
Overload
ToXml() |
Membuat pengodean XML objek keamanan dan statusnya saat ini. |
ToXml(PolicyLevel) |
Membuat pengodean XML objek keamanan dan statusnya saat ini, menggunakan konteks tingkat kebijakan yang ditentukan. |
ToXml()
- Sumber:
- GacMembershipCondition.cs
- Sumber:
- GacMembershipCondition.cs
- Sumber:
- GacMembershipCondition.cs
Membuat pengodean XML objek keamanan dan statusnya saat ini.
public:
virtual System::Security::SecurityElement ^ ToXml();
public System.Security.SecurityElement ToXml ();
abstract member ToXml : unit -> System.Security.SecurityElement
override this.ToXml : unit -> System.Security.SecurityElement
Public Function ToXml () As SecurityElement
Mengembalikan
SecurityElement yang berisi pengodean XML objek keamanan, termasuk informasi status apa pun.
Penerapan
Contoh
Contoh kode berikut menunjukkan penggunaan ToXml metode . Contoh ini adalah bagian dari contoh yang lebih besar yang disediakan untuk GacMembershipCondition kelas .
GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
GacMembershipCondition ^ Gac2 = gcnew GacMembershipCondition;
// Roundtrip a GacMembershipCondition to and from an XML encoding.
Gac2->FromXml(Gac1->ToXml());
bool result = Gac2->Equals(Gac1);
if (result)
{
Console::WriteLine("Result of ToXml() = {0}", Gac2->ToXml());
Console::WriteLine(
"Result of ToFromXml roundtrip = {0}", Gac2);
}
else
{
Console::WriteLine(Gac2->ToString());
Console::WriteLine(Gac1->ToString());
return false;
}
GacMembershipCondition Gac1 = new GacMembershipCondition();
GacMembershipCondition Gac2 = new GacMembershipCondition();
// Roundtrip a GacMembershipCondition to and from an XML encoding.
Gac2.FromXml(Gac1.ToXml());
bool result = Gac2.Equals(Gac1);
if (result)
{
Console.WriteLine(
"Result of ToXml() = " + Gac2.ToXml().ToString());
Console.WriteLine(
"Result of ToFromXml roundtrip = " + Gac2.ToString());
}
else
{
Console.WriteLine(Gac2.ToString());
Console.WriteLine(Gac1.ToString());
return false;
}
Dim Gac1 As New GacMembershipCondition
Dim Gac2 As New GacMembershipCondition
' Roundtrip a GacMembershipCondition to and from an XML encoding.
Gac2.FromXml(Gac1.ToXml())
Dim result As Boolean = Gac2.Equals(Gac1)
If result Then
Console.WriteLine(("Result of ToXml() = " & _
Gac2.ToXml().ToString()))
Console.WriteLine(("Result of ToFromXml roundtrip = " & _
Gac2.ToString()))
Else
Console.WriteLine(Gac2.ToString())
Console.WriteLine(Gac1.ToString())
Return False
End If
Keterangan
FromXml Gunakan metode untuk memulihkan informasi status dari SecurityElement.
Berlaku untuk
ToXml(PolicyLevel)
- Sumber:
- GacMembershipCondition.cs
- Sumber:
- GacMembershipCondition.cs
- Sumber:
- GacMembershipCondition.cs
Membuat pengodean XML objek keamanan dan statusnya saat ini, menggunakan konteks tingkat kebijakan yang ditentukan.
public:
virtual System::Security::SecurityElement ^ ToXml(System::Security::Policy::PolicyLevel ^ level);
public System.Security.SecurityElement ToXml (System.Security.Policy.PolicyLevel level);
abstract member ToXml : System.Security.Policy.PolicyLevel -> System.Security.SecurityElement
override this.ToXml : System.Security.Policy.PolicyLevel -> System.Security.SecurityElement
Public Function ToXml (level As PolicyLevel) As SecurityElement
Parameter
- level
- PolicyLevel
Konteks PolicyLevel untuk menyelesaikan NamedPermissionSet referensi.
Mengembalikan
SecurityElement yang berisi pengodean XML objek keamanan, termasuk informasi status apa pun.
Penerapan
Contoh
Contoh kode berikut menunjukkan penggunaan ToXml metode . Contoh ini adalah bagian dari contoh yang lebih besar yang disediakan untuk GacMembershipCondition kelas .
GacMembershipCondition ^ Gac3 = gcnew GacMembershipCondition;
GacMembershipCondition ^ Gac4 = gcnew GacMembershipCondition;
IEnumerator^ policyEnumerator = SecurityManager::PolicyHierarchy();
while (policyEnumerator->MoveNext())
{
PolicyLevel^ currentLevel =
dynamic_cast<PolicyLevel^>(policyEnumerator->Current);
if (currentLevel->Label->Equals("Machine"))
{
Console::WriteLine("Result of ToXml(level) = {0}",
Gac3->ToXml(currentLevel));
Gac4->FromXml(Gac3->ToXml(), currentLevel);
Console::WriteLine(
"Result of FromXml(element, level) = {0}", Gac4);
}
}
GacMembershipCondition Gac3 = new GacMembershipCondition();
GacMembershipCondition Gac4 = new GacMembershipCondition();
IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy();
while (policyEnumerator.MoveNext())
{
PolicyLevel currentLevel =
(PolicyLevel)policyEnumerator.Current;
if (currentLevel.Label == "Machine")
{
Console.WriteLine("Result of ToXml(level) = " +
Gac3.ToXml(currentLevel));
Gac4.FromXml(Gac3.ToXml(), currentLevel);
Console.WriteLine("Result of FromXml(element, level) = " +
Gac4.ToString());
}
}
Dim Gac3 As New GacMembershipCondition
Dim Gac4 As New GacMembershipCondition
Dim policyEnumerator As IEnumerator = _
SecurityManager.PolicyHierarchy()
While policyEnumerator.MoveNext()
Dim currentLevel As PolicyLevel = _
CType(policyEnumerator.Current, PolicyLevel)
If currentLevel.Label = "Machine" Then
Console.WriteLine(("Result of ToXml(level) = " & _
Gac3.ToXml(currentLevel).ToString()))
Gac4.FromXml(Gac3.ToXml(), currentLevel)
Console.WriteLine(("Result of FromXml(element, level) = " _
& Gac4.ToString()))
End If
End While
Keterangan
Konteks tingkat kebijakan disediakan untuk resolusi referensi set izin bernama. Misalnya, grup kode menggunakan tingkat kebijakan untuk menemukan set izin bernama.