共用方式為


GacMembershipCondition.FromXml 方法

定義

使用指定的 XML 編碼,重建安全性物件。

多載

FromXml(SecurityElement)

使用指定的 XML 編碼,重建安全性物件。

FromXml(SecurityElement, PolicyLevel)

使用指定的 XML 編碼,以指定的原則層級內容重建安全性物件。

FromXml(SecurityElement)

來源:
GacMembershipCondition.cs
來源:
GacMembershipCondition.cs
來源:
GacMembershipCondition.cs

使用指定的 XML 編碼,重建安全性物件。

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

參數

e
SecurityElement

SecurityElement,包含用來重建安全性物件的 XML 編碼。

實作

例外狀況

enull

e 不是有效的成員資格條件項目。

範例

下列程式碼範例顯示 方法的使用 FromXml 方式。 此範例是針對 類別提供的較大範例的 GacMembershipCondition 一部分。

GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
GacMembershipCondition ^ Gac2 = gcnew GacMembershipCondition;

// Roundtrip a GacMembershipCondition to and from an XML encoding.
Gac2->FromXml(Gac1->ToXml());
bool result = Gac2->Equals(Gac1);
if (result)
{
    Console::WriteLine("Result of ToXml() = {0}", Gac2->ToXml());
    Console::WriteLine(
        "Result of ToFromXml roundtrip = {0}", Gac2);
}
else
{
    Console::WriteLine(Gac2->ToString());
    Console::WriteLine(Gac1->ToString());
    return false;
}
GacMembershipCondition Gac1 = new GacMembershipCondition();
GacMembershipCondition Gac2 = new GacMembershipCondition();

// Roundtrip a GacMembershipCondition to and from an XML encoding.
Gac2.FromXml(Gac1.ToXml());
bool result = Gac2.Equals(Gac1);
if (result)
{
    Console.WriteLine(
        "Result of ToXml() = " + Gac2.ToXml().ToString());
    Console.WriteLine(
        "Result of ToFromXml roundtrip = " + Gac2.ToString());
}
else
{
    Console.WriteLine(Gac2.ToString());
    Console.WriteLine(Gac1.ToString());
    return false;
}
Dim Gac1 As New GacMembershipCondition
Dim Gac2 As New GacMembershipCondition

' Roundtrip a GacMembershipCondition to and from an XML encoding.
Gac2.FromXml(Gac1.ToXml())
Dim result As Boolean = Gac2.Equals(Gac1)
If result Then
    Console.WriteLine(("Result of ToXml() = " & _ 
        Gac2.ToXml().ToString()))
    Console.WriteLine(("Result of ToFromXml roundtrip = " & _ 
        Gac2.ToString()))
Else
    Console.WriteLine(Gac2.ToString())
    Console.WriteLine(Gac1.ToString())
    Return False
End If

備註

方法 FromXmlGacMembershipCondition 從 類別所 SecurityElement 定義的 XML 編碼重新建構 。 ToXml使用 方法來 XML 編碼 GacMembershipCondition 包含狀態資訊。

適用於

FromXml(SecurityElement, PolicyLevel)

來源:
GacMembershipCondition.cs
來源:
GacMembershipCondition.cs
來源:
GacMembershipCondition.cs

使用指定的 XML 編碼,以指定的原則層級內容重建安全性物件。

public:
 virtual void FromXml(System::Security::SecurityElement ^ e, System::Security::Policy::PolicyLevel ^ level);
public void FromXml (System.Security.SecurityElement e, System.Security.Policy.PolicyLevel level);
abstract member FromXml : System.Security.SecurityElement * System.Security.Policy.PolicyLevel -> unit
override this.FromXml : System.Security.SecurityElement * System.Security.Policy.PolicyLevel -> unit
Public Sub FromXml (e As SecurityElement, level As PolicyLevel)

參數

e
SecurityElement

SecurityElement,包含用來重建安全性物件的 XML 編碼。

level
PolicyLevel

PolicyLevel 內容,用於解析 NamedPermissionSet 參考。

實作

例外狀況

enull

e 不是有效的成員資格條件項目。

範例

下列程式碼範例顯示 方法的使用 FromXml 方式。 此範例是針對 類別提供的較大範例的 GacMembershipCondition 一部分。

GacMembershipCondition ^ Gac3 = gcnew GacMembershipCondition;
GacMembershipCondition ^ Gac4 = gcnew GacMembershipCondition;
IEnumerator^ policyEnumerator = SecurityManager::PolicyHierarchy();
while (policyEnumerator->MoveNext())
{
    PolicyLevel^ currentLevel = 
        dynamic_cast<PolicyLevel^>(policyEnumerator->Current);
    if (currentLevel->Label->Equals("Machine"))
    {
        Console::WriteLine("Result of ToXml(level) = {0}", 
            Gac3->ToXml(currentLevel));
        Gac4->FromXml(Gac3->ToXml(), currentLevel);
        Console::WriteLine(
            "Result of FromXml(element, level) = {0}", Gac4);
    }
}
GacMembershipCondition Gac3 = new GacMembershipCondition();
GacMembershipCondition Gac4 = new GacMembershipCondition();
IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy();
while (policyEnumerator.MoveNext())
{
    PolicyLevel currentLevel = 
        (PolicyLevel)policyEnumerator.Current;
    if (currentLevel.Label == "Machine")
    {
        Console.WriteLine("Result of ToXml(level) = " + 
            Gac3.ToXml(currentLevel));
        Gac4.FromXml(Gac3.ToXml(), currentLevel);
        Console.WriteLine("Result of FromXml(element, level) = " + 
            Gac4.ToString());
    }
}
Dim Gac3 As New GacMembershipCondition
Dim Gac4 As New GacMembershipCondition
Dim policyEnumerator As IEnumerator = _
    SecurityManager.PolicyHierarchy()
While policyEnumerator.MoveNext()
    Dim currentLevel As PolicyLevel = _
        CType(policyEnumerator.Current, PolicyLevel)
    If currentLevel.Label = "Machine" Then
        Console.WriteLine(("Result of ToXml(level) = " & _
            Gac3.ToXml(currentLevel).ToString()))
        Gac4.FromXml(Gac3.ToXml(), currentLevel)
        Console.WriteLine(("Result of FromXml(element, level) = " _
            & Gac4.ToString()))
    End If
End While

備註

系統會提供原則層級內容來解析具名許可權集合參考。 例如,程式碼群組會使用原則層級來尋找具名許可權集合。

適用於