StrongNameIdentityPermission.FromXml(SecurityElement) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 XML 编码重新构造具有指定状态的权限。
public:
override void FromXml(System::Security::SecurityElement ^ e);
public override void FromXml (System.Security.SecurityElement e);
override this.FromXml : System.Security.SecurityElement -> unit
Public Overrides Sub FromXml (e As SecurityElement)
参数
用于重新构造权限的 XML 编码。
例外
e
参数为 null
。
示例
下面的代码示例演示 方法的行为 FromXml 。 此示例是为 类提供的更大示例的一 StrongNameIdentityPermission 部分。 此示例的最佳用途是生成并执行整个示例,并查看其输出。
注意
代码示例旨在显示方法的行为,而不是演示其用法。 通常,安全基础结构使用权限类的方法;它们通常不用于应用程序。
// 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
注解
应用程序代码不使用此方法。