GacMembershipCondition.FromXml Method

Definition

Uses the specified XML encoding to reconstruct a security object.

Overloads

FromXml(SecurityElement)

Uses the specified XML encoding to reconstruct a security object.

FromXml(SecurityElement, PolicyLevel)

Uses the specified XML encoding to reconstruct a security object, using the specified policy level context.

FromXml(SecurityElement)

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

Uses the specified XML encoding to reconstruct a security object.

C#
public void FromXml(System.Security.SecurityElement e);

Parameters

e
SecurityElement

The SecurityElement that contains the XML encoding to use to reconstruct the security object.

Implements

Exceptions

e is not a valid membership condition element.

Examples

The following code example shows the use of the FromXml method. This example is part of a larger example provided for the GacMembershipCondition class.

C#
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;
}

Remarks

The FromXml method reconstructs a GacMembershipCondition from an XML encoding defined by the SecurityElement class. Use the ToXml method to XML-encode the GacMembershipCondition including state information.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

FromXml(SecurityElement, PolicyLevel)

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

Uses the specified XML encoding to reconstruct a security object, using the specified policy level context.

C#
public void FromXml(System.Security.SecurityElement e, System.Security.Policy.PolicyLevel level);

Parameters

e
SecurityElement

The SecurityElement that contains the XML encoding to use to reconstruct the security object.

level
PolicyLevel

The PolicyLevel context for resolving NamedPermissionSet references.

Implements

Exceptions

e is not a valid membership condition element.

Examples

The following code example shows the use of the FromXml method. This example is part of a larger example provided for the GacMembershipCondition class.

C#
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());
    }
}

Remarks

The policy level context is provided for resolution of named permission set references. For example, code groups use policy level to find named permission sets.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10