Equals() public méthode

public Equals ( object o ) : bool
o object
Résultat bool
Exemple #1
0
 public static void PolicyStatementCallMethods()
 {
     PolicyStatement ps = new PolicyStatement(new PermissionSet(new PermissionState()));
     PolicyStatement ps2 = ps.Copy();
     bool equals = ps.Equals(ps2);
     int hash = ps.GetHashCode();
     SecurityElement se = new SecurityElement("");
     PolicyLevel pl = (PolicyLevel)Activator.CreateInstance(typeof(PolicyLevel), true);
     ps.FromXml(se);
     ps.FromXml(se, pl);
     se = ps.ToXml();
     se = ps.ToXml(pl);
 }
		public void Equals ()
		{
			PolicyStatement empty1 = new PolicyStatement (null);
			PolicyStatement empty2 = new PolicyStatement (null);
			Assert.IsTrue (empty1.Equals (empty2), "empty1.Equals (empty2)");
			Assert.IsTrue (empty2.Equals (empty1), "empty2.Equals (empty1)");
			Assert.IsFalse (Object.ReferenceEquals (empty1, empty2), "!ReferenceEquals");

			PolicyStatement unr1 = new PolicyStatement (Unrestricted, PolicyStatementAttribute.All);
			Assert.IsFalse (unr1.Equals (empty1), "unr1.Equals (empty1)");
			Assert.IsFalse (empty1.Equals (unr1), "empty1.Equals (unr1)");

			PolicyStatement unr2 = new PolicyStatement (Unrestricted, PolicyStatementAttribute.Exclusive);
			Assert.IsFalse (unr1.Equals (unr2), "unr1.Equals (unr2)");
			Assert.IsFalse (unr2.Equals (unr1), "unr2.Equals (unr1)");

			PolicyStatement unr3 = unr2.Copy ();
			Assert.IsTrue (unr3.Equals (unr2), "unr3.Equals (unr2)");
			Assert.IsTrue (unr2.Equals (unr3), "unr2.Equals (unr3)");
		}