コード例 #1
0
        public int CompareTo(MetricSamplePacket other)
        {
            //First do a quick match on Guid.  this is the only case we want to return zero (an exact match)
            if (ID == other.ID)
            {
                return(0);
            }

            //now we want to sort by our nice increasing sequence #
            int compareResult = Sequence.CompareTo(other.Sequence);

            Debug.Assert(compareResult != 0); //no way we should ever get an equal at this point.

            return(compareResult);
        }
コード例 #2
0
        /// <summary>
        /// Determines if the provided object is identical to this object.
        /// </summary>
        /// <param name="other">The object to compare this object to</param>
        /// <returns>True if the objects represent the same data.</returns>
        public bool Equals(MetricSamplePacket other)
        {
            //Careful - can be null
            if (other == null)
            {
                return(false); // since we're a live object we can't be equal.
            }

            return((ID == other.ID) &&
                   (((m_MetricPacket == null) && (other.MetricPacket == null)) ||
                    (((m_MetricPacket != null) && (other.MetricPacket != null)) && (m_MetricPacket.ID == other.MetricPacket.ID))) &&
                   (base.Equals(other)));
            // Bug: (?) Should Equals also be comparing on MetricID field?
            // Note: I wonder if we should be digging into MetricPacket.ID fields directly like this
            // or if it would be better to invoke m_MetricPacket.Equals(other.MetricPacket) (but less efficient?)
        }