Share via


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

설명

보안 개체를 확장하는 사용자 지정 코드는 및 FromXml 메서드를 ToXml 구현하여 개체를 보안 인코딩할 수 있도록 해야 합니다.

구현자 참고

파생 클래스에서 이 메서드를 재정의해야 합니다.

적용 대상