Freigeben über


StrongNameIdentityPermission.ToXml Methode

Definition

Erstellt eine XML-Codierung der Berechtigung und ihres aktuellen Zustands.

public:
 override System::Security::SecurityElement ^ ToXml();
public override System.Security.SecurityElement ToXml ();
override this.ToXml : unit -> System.Security.SecurityElement
Public Overrides Function ToXml () As SecurityElement

Gibt zurück

Eine XML-Codierung der Berechtigung, einschließlich aller Zustandsinformationen.

Beispiele

Das folgende Codebeispiel zeigt das Verhalten der ToXml -Methode.

Hinweis

Das Codebeispiel soll das Verhalten der Methode und nicht deren Verwendung veranschaulichen. Im Allgemeinen werden die Methoden der Berechtigungsklassen von der Sicherheitsinfrastruktur verwendet. sie werden in der Regel nicht in Anwendungen verwendet.

    // 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 returnValue = true;
        StrongNameIdentityPermission^ snIdPerm1;
        StrongNameIdentityPermission^ snIdPerm2;
        snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));    
        snIdPerm2 = gcnew StrongNameIdentityPermission(PermissionState::None);
        snIdPerm2->FromXml(snIdPerm1->ToXml());
        Console::WriteLine("Result of ToFromXml = " + snIdPerm2->ToString() + "\n");

        return returnValue;
    }


public:
// 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 returnValue = true;

    StrongNameIdentityPermission snIdPerm1, snIdPerm2;

    snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));    
    snIdPerm2 = new StrongNameIdentityPermission(PermissionState.None);
    snIdPerm2.FromXml(snIdPerm1.ToXml());
    Console.WriteLine("Result of ToFromXml = " + snIdPerm2.ToString() + "\n");

    return returnValue;
}
' 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 returnValue As Boolean = True
    
    Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
    
    snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
    snIdPerm2 = New StrongNameIdentityPermission(PermissionState.None)
    snIdPerm2.FromXml(snIdPerm1.ToXml())
    Console.WriteLine("Result of ToFromXml = " + snIdPerm2.ToString() + vbLf)
    
    Return returnValue

End Function 'ToFromXmlDemo

Hinweise

Diese Methode wird in der Regel nicht vom Anwendungscode verwendet.

Gilt für: