UIPermission.FromXml(SecurityElement) 메서드

정의

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)

매개 변수

esd
SecurityElement

권한을 다시 생성하는 데 사용되는 XML 인코딩입니다.

예외

esd 매개 변수가 null인 경우

esd 매개 변수가 올바른 사용 권한 요소가 아닌 경우

또는 esd 매개 변수의 버전 번호가 잘못된 경우

예제

다음 코드 예제에서는 메서드의 동작을 FromXml 보여줍니다. 이 예제는에 대해 제공 된 큰 예제의 일부는 UIPermission 클래스입니다.

참고

코드 예제는 메서드의 사용을 보여 주는 것이 아니라 메서드의 동작을 표시하기 위한 것입니다. 으로 보안 인프라를 권한 클래스의 메서드를 사용 하는 일반적으로 애플리케이션에서 사용 되지 됩니다.


// 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

적용 대상