예제 #1
0
        public int CompareTo(DnsRecordBase other)
        {
            int compare = Name.CompareTo(other.Name);

            if (compare != 0)
            {
                return(compare);
            }

            compare = RecordType.CompareTo(other.RecordType);
            if (compare != 0)
            {
                return(compare);
            }

            compare = RecordClass.CompareTo(other.RecordClass);
            if (compare != 0)
            {
                return(compare);
            }

            compare = TimeToLive.CompareTo(other.TimeToLive);
            if (compare != 0)
            {
                return(compare);
            }

            int maxLength = 2 + Math.Max(MaximumRecordDataLength, other.MaximumRecordDataLength);

            byte[] thisBuffer = new byte[maxLength];
            int    thisLength = 0;

            EncodeRecordBody(thisBuffer, 0, ref thisLength, null, false);

            byte[] otherBuffer = new byte[maxLength];
            int    otherLength = 0;

            other.EncodeRecordBody(otherBuffer, 0, ref otherLength, null, false);

            for (int i = 0; i < Math.Min(thisLength, otherLength); i++)
            {
                compare = thisBuffer[i].CompareTo(otherBuffer[i]);
                if (compare != 0)
                {
                    return(compare);
                }
            }

            return(thisLength.CompareTo(otherLength));
        }
예제 #2
0
        /// <inheritdoc />
        public Int32 CompareTo(WebCookie other)
        {
            var cmp = Domain?.CompareTo(other.Domain ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Path?.CompareTo(other.Path ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Key?.CompareTo(other.Key ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Value?.CompareTo(other.Value ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = TimeToLive?.CompareTo(other.TimeToLive ?? TimeSpan.Zero) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            return(GetHashCode().CompareTo(other.GetHashCode()));
        }