GacMembershipCondition.ToXml Méthode

Définition

Crée un encodage XML de l’objet de sécurité et son état actuel.

Surcharges

Nom Description
ToXml()

Crée un encodage XML de l’objet de sécurité et son état actuel.

ToXml(PolicyLevel)

Crée un encodage XML de l’objet de sécurité et de son état actuel, à l’aide du contexte de niveau de stratégie spécifié.

ToXml()

Crée un encodage XML de l’objet de sécurité et son état actuel.

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

Retours

Qui SecurityElement contient l’encodage XML de l’objet de sécurité, y compris les informations d’état.

Implémente

Exemples

L’exemple de code suivant montre l’utilisation de la ToXml méthode. Cet exemple fait partie d’un exemple plus large fourni pour la GacMembershipCondition classe.

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

Remarques

Utilisez la FromXml méthode pour restaurer les informations d’état à partir d’un SecurityElement.

S’applique à

ToXml(PolicyLevel)

Crée un encodage XML de l’objet de sécurité et de son état actuel, à l’aide du contexte de niveau de stratégie spécifié.

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

Paramètres

level
PolicyLevel

Contexte PolicyLevel de résolution NamedPermissionSet des références.

Retours

Qui SecurityElement contient l’encodage XML de l’objet de sécurité, y compris les informations d’état.

Implémente

Exemples

L’exemple de code suivant montre l’utilisation de la ToXml méthode. Cet exemple fait partie d’un exemple plus large fourni pour la GacMembershipCondition classe.

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

Remarques

Le contexte de niveau de stratégie est fourni pour la résolution des références de jeu d’autorisations nommées. Par exemple, les groupes de code utilisent le niveau de stratégie pour rechercher des jeux d’autorisations nommés.

S’applique à