Apache.NMS.ActiveMQ.Commands.ConsumerId.Equals C# (CSharp) Метод

Equals() публичный Метод

public Equals ( ConsumerId that ) : bool
that ConsumerId
Результат bool
        public virtual bool Equals(ConsumerId that)
        {
            if(!Equals(this.ConnectionId, that.ConnectionId))
            {
                return false;
            }
            if(!Equals(this.SessionId, that.SessionId))
            {
                return false;
            }
            if(!Equals(this.Value, that.Value))
            {
                return false;
            }

            return true;
        }

Same methods

ConsumerId::Equals ( object that ) : bool

Usage Example

Пример #1
0
 public void TestCommand()
 {
     ConsumerId value1 = new ConsumerId();
     value1.ConnectionId = "abc";
     value1.SessionId = 123;
     value1.Value = 456;
     
     ConsumerId value2 = new ConsumerId();
     value2.ConnectionId = "abc";
     value2.SessionId = 123;
     value2.Value = 456;
     
     ConsumerId value3 = new ConsumerId();
     value3.ConnectionId = "abc";
     value3.SessionId = 123;
     value3.Value = 457;
     
     Assert.AreEqual(value1, value2, "value1 and value2 should be equal");
     Assert.AreEqual(value1.GetHashCode(), value2.GetHashCode(), "value1 and value2 hash codes should be equal");
     
     Assert.IsTrue(!value1.Equals(value3), "value1 and value3 should not be equal");
     Assert.IsTrue(!value3.Equals(value2), "value3 and value2 should not be equal");
     
     // now lets test an IDictionary
     IDictionary dictionary = new Hashtable();
     dictionary[value1] = value3;
     
     // now lets lookup with a copy
     object actual = dictionary[value2];
     
     Assert.AreEqual(value3, actual, "Should have found item in Map using value2 as a key");
 }