次の方法で共有


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 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

注釈

セキュリティ オブジェクトを拡張するカスタム コードでは、 メソッドと FromXml メソッドをToXml実装してオブジェクトをセキュリティエンコダブルにする必要があります。

適用対象