UIPermission.FromXml(SecurityElement) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 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
。
示例
下面的代码示例演示 方法的行为 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