CodeAccessPermission.FromXml(SecurityElement) 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当在派生类中替代时,用 XML 编码重新构造具有指定状态的安全对象。
public:
 abstract void FromXml(System::Security::SecurityElement ^ elem);public abstract void FromXml(System.Security.SecurityElement elem);abstract member FromXml : System.Security.SecurityElement -> unitPublic MustOverride Sub FromXml (elem As SecurityElement)参数
- elem
- SecurityElement
用于重新构造安全对象的 XML 编码。
实现
例外
              elem 参数为 null。
示例
下面的代码示例演示 方法的 FromXml 替代。 此代码示例是为 CodeAccessPermission 类提供的一个更大示例的一部分。
public:
   virtual void FromXml( SecurityElement^ e ) override
   {
      // The following code for unrestricted permission is only included as an example for
      // permissions that allow the unrestricted state. It is of no value for this permission.
      String^ elUnrestricted = e->Attribute("Unrestricted");
      if ( nullptr != elUnrestricted )
      {
         m_Unrestricted = Boolean::Parse( elUnrestricted );
         return;
      }
      String^ elName = e->Attribute("Name");
      m_Name = elName == nullptr ? nullptr : elName;
   }
public override void FromXml(SecurityElement e)
 {
     // The following code for unrestricted permission is only included as an example for
     // permissions that allow the unrestricted state. It is of no value for this permission.
     String elUnrestricted = e.Attribute("Unrestricted");
     if (null != elUnrestricted)
     {
         m_Unrestricted = bool.Parse(elUnrestricted);
         return;
     }
     String elName = e.Attribute( "Name" );
     m_Name = elName == null ? null : elName;
 }
Public Overrides Sub FromXml(ByVal e As SecurityElement)
    ' The following code for unrestricted permission is only included as an example for
    ' permissions that allow the unrestricted state. It is of no value for this permission.
    Dim elUnrestricted As String = e.Attribute("Unrestricted")
    If Nothing <> elUnrestricted Then
        m_Unrestricted = Boolean.Parse(elUnrestricted)
        Return
    End If
    Dim elName As String = e.Attribute("Name")
    m_name = IIf(elName Is Nothing, Nothing, elName)
End Sub
注解
扩展安全对象的自定义代码需要实现 ToXml 和 FromXml 方法,使对象可安全编码。
实施者说明
必须在派生类中重写此方法。