CodeAccessPermission.FromXml(SecurityElement) メソッド

定義

派生クラスでオーバーライドされると、XML エンコードから指定された状態で、セキュリティ オブジェクトを再構築します。

public:
 abstract void FromXml(System::Security::SecurityElement ^ elem);
public abstract void FromXml (System.Security.SecurityElement elem);
abstract member FromXml : System.Security.SecurityElement -> unit
Public MustOverride Sub FromXml (elem As SecurityElement)

パラメーター

elem
SecurityElement

セキュリティ オブジェクトの再構築に使用する XML エンコード。

実装

例外

elem パラメーターが null です。

elem パラメーターに、現在のインスタンスと同じ型のインスタンスの XML エンコーディングが含まれていません。

または elem パラメーターのバージョン番号は、サポートされていません。

次のコード例は、メソッドのオーバーライドを 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 メソッドを実装する必要があります。

注意 (実装者)

派生クラスでこのメソッドをオーバーライドする必要があります。

適用対象