This documentation is archived and is not being maintained.

PublisherIdentityPermission.IsSubsetOf Method

Determines whether the current permission is a subset of the specified permission.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

public override bool IsSubsetOf (
	IPermission target
)
public boolean IsSubsetOf (
	IPermission target
)
public override function IsSubsetOf (
	target : IPermission
) : boolean

Parameters

target

A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission.

Return Value

true if the current permission is a subset of the specified permission; otherwise, false.

Exception typeCondition

ArgumentException

The target parameter is not a null reference (Nothing in Visual Basic) and is not of the same type as the current permission.

The current permission is a subset of the specified permission if the two permissions are equal. If this method returns true, the current permission represents the same access to the protected resource as the specified permission.

PublisherIdentityPermission supports set operations (IsSubsetOf, Intersect, and Union) only when the current permission is equal to the specified permission.

The following example shows the results of the use of the IsSubsetOf method, not how to use the method. This code is part of a larger example. The best use for this example is to build and execute the entire example, and view its output. For the complete example, refer to the PublisherIdentityPermission class.

private bool IsSubsetOfDemo()
{

    bool retCode = true;

    String publisher1, publisher2;
    PublisherIdentityPermission pubIdPerm1, pubIdPerm2;

    PublisherGenerator pubGen1 = new PublisherGenerator();
    PublisherGenerator pubGen2 = new PublisherGenerator();

    pubGen1.ResetIndex();
    while (pubGen1.CreatePublisher(out pubIdPerm1, out publisher1))
    {
        if (pubIdPerm1 == null) continue;
        pubGen2.ResetIndex();
        while (pubGen2.CreatePublisher(out pubIdPerm2, out publisher2))
        {
            if (pubIdPerm2 == null) continue;

            try
            {
                // Check for whether either of the publishers is null.
                // An exception will be thrown if either is null.
                if (publisher1 != "null" && publisher2 != "null")
                {
                    if (pubIdPerm1.IsSubsetOf(pubIdPerm2))
                    {
                        Console.WriteLine(pubIdPerm1.Certificate.GetName() +
                            " is a subset of " + pubIdPerm2.Certificate.GetName() + "\n");
                    }
                    else
                    {
                        Console.WriteLine(pubIdPerm1.Certificate.GetName() +
                            " is not a subset of " + pubIdPerm2.Certificate.GetName() + "\n");
                    }
                }

            }
            catch
            {
                Console.WriteLine("An exception was thrown for " + publisher1 + " is a subset of " +
                    publisher2 + "\n.");
                retCode = false;
            }

        }
    }


    return retCode;
}

private boolean IsSubsetOfDemo() 
{
    boolean retCode = true;
    String publisher1 = null;
    String publisher2 = null;
    PublisherIdentityPermission pubIdPerm1 = null; 
    PublisherIdentityPermission pubIdPerm2 = null;
    
    PublisherGenerator pubGen1 =  new PublisherGenerator();
    PublisherGenerator pubGen2 =  new PublisherGenerator();
    
    pubGen1.ResetIndex();
    while(pubGen1.CreatePublisher(pubIdPerm1, publisher1)) {
        if (pubIdPerm1 == null) {
            continue ;
        }
        pubGen2.ResetIndex();
        while(pubGen2.CreatePublisher(pubIdPerm2, publisher2)) {
            if (pubIdPerm2 == null) {
                continue ;
            }
            
            try {
                // Check for whether either of the publishers is null.
                // An exception will be thrown if either is null.
                if (publisher1 != "null" && publisher2 != "null") {
                    if ( pubIdPerm1.IsSubsetOf(pubIdPerm2)  ) {
                        Console.WriteLine((pubIdPerm1.get_Certificate().
                        GetName() + " is a subset of " 
                            + pubIdPerm2.get_Certificate().GetName() 
                            + "\n"));
                    }
                    else {
                        Console.WriteLine((pubIdPerm1.get_Certificate().
                        GetName() + " is not a subset of " 
                            + pubIdPerm2.get_Certificate().GetName() 
                            + "\n"));
                    }
                }
            }
            catch(System.Exception exp){
                    Console.WriteLine(("An exception was thrown for " 
                        + publisher1 + " is a subset of " + publisher2 
                        + "\n."));
                    retCode = false;
            }
        }
    }
    return retCode ;
} //IsSubsetOfDemo   

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: