public void Union() { StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(ecma); StrongNameIdentityPermission snip = new StrongNameIdentityPermission(blob, "mono", new Version(1, 2, 3, 4)); StrongNameIdentityPermission union = (StrongNameIdentityPermission)snip.Union(null); Compare(snip, union, "snip U null"); StrongNameIdentityPermission empty = new StrongNameIdentityPermission(PermissionState.None); union = (StrongNameIdentityPermission)snip.Union(empty); Compare(snip, union, "snip U empty"); union = (StrongNameIdentityPermission)snip.Union(snip); Compare(snip, union, "snip U snip"); // note: can't be tested with PermissionState.Unrestricted StrongNameIdentityPermission samePk = new StrongNameIdentityPermission(blob, null, null); union = (StrongNameIdentityPermission)snip.Union(samePk); #if !NET_2_0 // can't compare the properties with multiple entries Compare(snip, union, "snip U samePk"); #endif Assert.IsTrue(snip.IsSubsetOf(union), "snip.IsSubsetOf (union)"); union = (StrongNameIdentityPermission)samePk.Union(snip); #if !NET_2_0 // can't compare the properties with multiple entries Compare(snip, union, "samePk U snip"); #endif Assert.IsTrue(samePk.IsSubsetOf(union), "snip.IsSubsetOf (union)"); }
public void IsSubsetOf_DifferentPermissions() { StrongNameIdentityPermission a = new StrongNameIdentityPermission(PermissionState.None); SecurityPermission b = new SecurityPermission(PermissionState.None); a.IsSubsetOf(b); }
public void IsSubsetOf() { StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(ecma); StrongNameIdentityPermission snip = new StrongNameIdentityPermission(blob, "mono", new Version(1, 2, 3, 4)); Assert.IsFalse(snip.IsSubsetOf(null), "snip.IsSubsetOf (null)"); StrongNameIdentityPermission empty = new StrongNameIdentityPermission(PermissionState.None); Assert.IsTrue(empty.IsSubsetOf(null), "empty.IsSubsetOf (null)"); }
public static void StrongNameIdentityPermissionCallMethods() { StrongNameIdentityPermission snip = new StrongNameIdentityPermission(new Permissions.PermissionState()); StrongNameIdentityPermission snip2 = new StrongNameIdentityPermission(new Permissions.StrongNamePublicKeyBlob(new byte[1]), "test", new Version(1, 2)); IPermission ip = snip.Copy(); IPermission ip2 = snip.Intersect(ip); bool testbool = snip.IsSubsetOf(ip); ip2 = snip.Union(ip); SecurityElement se = new SecurityElement(""); snip.FromXml(se); se = snip.ToXml(); }
public void IsSubsetOf_Corlib() { Version fx11 = new Version(1, 0, 5000, 0); StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(ecma); StrongNameIdentityPermission granted = new StrongNameIdentityPermission(blob, "mscorlib", fx11); StrongNameIdentityPermission demanded = new StrongNameIdentityPermission(blob, null, null); Assert.IsTrue(demanded.IsSubsetOf(granted), "pk"); demanded = new StrongNameIdentityPermission(blob, "mscorlib", null); Assert.IsTrue(demanded.IsSubsetOf(granted), "pk+name"); demanded = new StrongNameIdentityPermission(blob, null, fx11); Assert.IsTrue(demanded.IsSubsetOf(granted), "pk+v"); demanded = new StrongNameIdentityPermission(blob, "mscorlib", fx11); Assert.IsTrue(demanded.IsSubsetOf(granted), "pk+name+v"); }
//<Snippet2> // IsSubsetOf determines whether the current permission is a subset of the specified permission. private bool IsSubsetOfDemo() { bool returnValue = true; StrongNameIdentityPermission snIdPerm1, snIdPerm2; //<Snippet8> snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0")); //</Snippet8> snIdPerm2 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", new Version("1.0.0.0")); if (snIdPerm1.IsSubsetOf(snIdPerm2)) { Console.WriteLine("MyCompany.MyDepartment.* is a subset " + "of MyCompany.MyDepartment.MyFile \n"); } else { Console.WriteLine("MyCompany.MyDepartment.*" + " is not a subset of MyCompany.MyDepartment.MyFile \n"); } return(returnValue); }
// IsSubsetOf determines whether the current permission is a subset of the specified permission. private bool IsSubsetOfDemo() { bool returnValue = true; StrongNameIdentityPermission snIdPerm1, snIdPerm2; snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0")); snIdPerm2 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", new Version("1.0.0.0")); if (snIdPerm1.IsSubsetOf(snIdPerm2)) { Console.WriteLine("MyCompany.MyDepartment.* is a subset " + "of MyCompany.MyDepartment.MyFile \n"); } else { Console.WriteLine("MyCompany.MyDepartment.*" + " is not a subset of MyCompany.MyDepartment.MyFile \n"); } return returnValue; }
public static void StrongNameIdentityPermissionCallMethods() { StrongNameIdentityPermission snip = new StrongNameIdentityPermission(new Permissions.PermissionState()); StrongNameIdentityPermission snip2 = new StrongNameIdentityPermission(new Permissions.StrongNamePublicKeyBlob(new byte[1]), "test", new System.Version(1, 2)); IPermission ip = snip.Copy(); IPermission ip2 = snip.Intersect(ip); bool testbool = snip.IsSubsetOf(ip); ip2 = snip.Union(ip); SecurityElement se = new SecurityElement(""); snip.FromXml(se); se = snip.ToXml(); }