다음을 통해 공유


GacMembershipCondition.ToXml 메서드

정의

보안 개체 및 현재 상태의 XML 인코딩을 만듭니다.

오버로드

ToXml()

보안 개체 및 현재 상태의 XML 인코딩을 만듭니다.

ToXml(PolicyLevel)

지정된 정책 수준 컨텍스트를 사용하여 보안 개체 및 해당 보안 개체의 현재 상태에 대한 XML 인코딩을 만듭니다.

ToXml()

Source:
GacMembershipCondition.cs
Source:
GacMembershipCondition.cs
Source:
GacMembershipCondition.cs
Source:
GacMembershipCondition.cs

보안 개체 및 현재 상태의 XML 인코딩을 만듭니다.

public:
 virtual System::Security::SecurityElement ^ ToXml();
public System.Security.SecurityElement ToXml ();
abstract member ToXml : unit -> System.Security.SecurityElement
override this.ToXml : unit -> System.Security.SecurityElement
Public Function ToXml () As SecurityElement

반환

상태 정보를 포함한 보안 개체의 XML 인코딩이 들어 있는 SecurityElement입니다.

구현

예제

다음 코드 예제에서는 사용 된 메서드입니다 ToXml . 이 예제는에 대해 제공 된 큰 예제의 일부는 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

설명

메서드를 FromXml 사용하여 에서 상태 정보를 복원합니다 SecurityElement.

적용 대상

ToXml(PolicyLevel)

Source:
GacMembershipCondition.cs
Source:
GacMembershipCondition.cs
Source:
GacMembershipCondition.cs
Source:
GacMembershipCondition.cs

지정된 정책 수준 컨텍스트를 사용하여 보안 개체 및 해당 보안 개체의 현재 상태에 대한 XML 인코딩을 만듭니다.

public:
 virtual System::Security::SecurityElement ^ ToXml(System::Security::Policy::PolicyLevel ^ level);
public System.Security.SecurityElement ToXml (System.Security.Policy.PolicyLevel level);
abstract member ToXml : System.Security.Policy.PolicyLevel -> System.Security.SecurityElement
override this.ToXml : System.Security.Policy.PolicyLevel -> System.Security.SecurityElement
Public Function ToXml (level As PolicyLevel) As SecurityElement

매개 변수

level
PolicyLevel

PolicyLevel 참조를 확인하는 데 사용되는 NamedPermissionSet 컨텍스트입니다.

반환

상태 정보를 포함한 보안 개체의 XML 인코딩이 들어 있는 SecurityElement입니다.

구현

예제

다음 코드 예제에서는 사용 된 메서드입니다 ToXml . 이 예제는에 대해 제공 된 큰 예제의 일부는 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

설명

명명된 권한 집합 참조를 확인하기 위해 정책 수준 컨텍스트가 제공됩니다. 예를 들어 코드 그룹은 정책 수준을 사용하여 명명된 권한 집합을 찾습니다.

적용 대상