UIPermission.FromXml(SecurityElement) Metodo

Definizione

Ricostruisce un'autorizzazione con uno stato specificato da una codifica XML.

public:
 override void FromXml(System::Security::SecurityElement ^ esd);
public override void FromXml (System.Security.SecurityElement esd);
override this.FromXml : System.Security.SecurityElement -> unit
Public Overrides Sub FromXml (esd As SecurityElement)

Parametri

esd
SecurityElement

Codifica XML usata per ricostruire l'autorizzazione.

Eccezioni

Il valore del parametro esd è null.

Il parametro esd non è un elemento di autorizzazione valido.

-oppure- Il numero di versione del parametro esd non è valido.

Esempio

Nell'esempio FromXml di codice seguente viene illustrato il comportamento del metodo. Questo esempio fa parte di un esempio più grande fornito per la UIPermission classe.

Nota

L'esempio di codice è destinato a mostrare il comportamento del metodo, non per illustrarne l'uso. In generale, i metodi delle classi di autorizzazione vengono usati dall'infrastruttura di sicurezza; non vengono in genere usati nelle applicazioni.


// ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
// permission with the specified state from the XML encoding.
void ToFromXmlDemo()
{
    Console::WriteLine("\n**********************  To/From XML() Demo *********************\n");

    UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows);
    UIPermission ^ uiPerm2 = gcnew UIPermission(PermissionState::None);
    uiPerm2->FromXml(uiPerm1->ToXml());
    bool result = uiPerm2->Equals(uiPerm1);
    if (result)
        Console::WriteLine("Result of ToFromXml = " + uiPerm2->ToString());
    else
        {
        Console::WriteLine(uiPerm2->ToString());
        Console::WriteLine(uiPerm1->ToString());
        }
}
// 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 static void ToFromXmlDemo()
{

    UIPermission uiPerm1 = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
    UIPermission uiPerm2 = new UIPermission(PermissionState.None);
    uiPerm2.FromXml(uiPerm1.ToXml());
    bool result = uiPerm2.Equals(uiPerm1);
    if (result)
    {
        Console.WriteLine("Result of ToFromXml = " + uiPerm2.ToString());
    }
    else
    {
        Console.WriteLine(uiPerm2.ToString());
        Console.WriteLine(uiPerm1.ToString());
    }
}
    ' 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 Shared Sub ToFromXmlDemo()


        Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
        Dim uiPerm2 As New UIPermission(PermissionState.None)
        uiPerm2.FromXml(uiPerm1.ToXml())
        Dim result As Boolean = uiPerm2.Equals(uiPerm1)
        If result Then
            Console.WriteLine("Result of ToFromXml = " + uiPerm2.ToString())
        Else
            Console.WriteLine(uiPerm2.ToString())
            Console.WriteLine(uiPerm1.ToString())
        End If

    End Sub
End Class

Si applica a