Example #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));
        }