System.Web.Configuration.AuthorizationRule.GetHashCode C# (CSharp) Method

GetHashCode() public method

public GetHashCode ( ) : int
return int
		public override int GetHashCode ()
		{
			int hashCode = (int)action;
			int i;

			for (i = 0; i < Roles.Count; i ++)
				hashCode += Roles[i].GetHashCode();

			for (i = 0; i < Users.Count; i ++)
				hashCode += Users[i].GetHashCode();

			for (i = 0; i < Verbs.Count; i ++)
				hashCode += Verbs[i].GetHashCode();

			return hashCode;
		}

Usage Example

Exemplo n.º 1
0
		public void Test_EqualsAndHashCode ()
		{
			AuthorizationRule a = new AuthorizationRule (AuthorizationRuleAction.Deny);
			AuthorizationRule b = new AuthorizationRule (AuthorizationRuleAction.Deny);

			a.Users.Add ("toshok");
			a.Roles.Add ("Admin");
			a.Verbs.Add ("reboot");

			b.Users.Add ("toshok");
			b.Roles.Add ("Admin");
			b.Verbs.Add ("reboot");

			Assert.AreEqual (a, b, "A1");
			Assert.AreEqual (a.GetHashCode (), b.GetHashCode (), "A2");
		}