ISecurityEncodable.FromXml(SecurityElement) 메서드

정의

XML 인코딩의 지정된 상태를 사용하여 보안 개체를 다시 만듭니다.

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

매개 변수

e
SecurityElement

보안 개체를 다시 만드는 데 사용할 XML 인코딩입니다.

예제

다음 코드 예제에서는 메서드 구현을 FromXml 보여 줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ISecurityEncodable 클래스입니다.

    // Populate the permission's fields from XML.
public:
    virtual void FromXml(SecurityElement^ element) override
    {
        specifiedAsUnrestricted = false;
        stateFlags = (SoundPermissionState)0;

        // If XML indicates an unrestricted permission, 
        // make this permission unrestricted.
        String^ attributeString = 
            (String^) element->Attributes["Unrestricted"];
        if (attributeString != nullptr)
        {
            specifiedAsUnrestricted = Convert::ToBoolean(attributeString);
            if (specifiedAsUnrestricted)
            {
                stateFlags = SoundPermissionState::PlayAnySound;
            }
        }

        // If XML indicates a restricted permission, parse the flags.
        if (!specifiedAsUnrestricted)
        {
            attributeString = (String^) element->Attributes["Flags"];
            if (attributeString != nullptr)
            {
                stateFlags = (SoundPermissionState) Convert::ToInt32(
                    Enum::Parse(SoundPermissionState::typeid, 
                    attributeString, true));
            }
        }
    }
// Populate the permission's fields from XML.
public override void FromXml(SecurityElement e)
{
    m_specifiedAsUnrestricted = false;
    m_flags = 0;

    // If XML indicates an unrestricted permission, make this permission unrestricted.
    String s = (String)e.Attributes["Unrestricted"];
    if (s != null)
    {
        m_specifiedAsUnrestricted = Convert.ToBoolean(s);
        if (m_specifiedAsUnrestricted)
            m_flags = SoundPermissionState.PlayAnySound;
    }

    // If XML indicates a restricted permission, parse the flags.
    if (!m_specifiedAsUnrestricted)
    {
        s = (String)e.Attributes["Flags"];
        if (s != null)
        {
            m_flags = (SoundPermissionState)
            Convert.ToInt32(Enum.Parse(typeof(SoundPermission), s, true));
        }
    }
}
' Populate the permission's fields from XML.
Public Overrides Sub FromXml(ByVal e As SecurityElement)
    m_specifiedAsUnrestricted = False
    m_flags = 0

    ' If XML indicates an unrestricted permission, make this permission unrestricted.
    Dim s As String = CStr(e.Attributes("Unrestricted"))
    If Not (s Is Nothing) Then
        m_specifiedAsUnrestricted = Convert.ToBoolean(s)
        If m_specifiedAsUnrestricted Then
            m_flags = SoundPermissionState.PlayAnySound
        End If
    End If
    ' If XML indicates a restricted permission, parse the flags.
    If Not m_specifiedAsUnrestricted Then
        s = CStr(e.Attributes("Flags"))
        If Not (s Is Nothing) Then
            m_flags = CType(Convert.ToInt32([Enum].Parse(GetType(SoundPermission), s, True)), SoundPermissionState)
        End If
    End If

End Sub

설명

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

적용 대상