예제 #1
0
        public override int CompareTo(object obj)
        {
            var nullValue = obj as NullValue;

            if (nullValue != null)
            {
                return(nullValue.Order == SortOrder.ASC ? int.MaxValue : int.MinValue);
            }

            int typeRule = DataType.CompareTo(((AttributeValue)obj).DataType);

            if (typeRule == 0)
            {
                bool countNotEquals = false;

                if (!(obj is MultiAttributeValue))
                {
                    throw new ArgumentException();
                }

                var other       = obj as MultiAttributeValue;
                int attribCount = _values.Count;

                if (countNotEquals = (_values.Count != other._values.Count))
                {
                    attribCount = Math.Min(_values.Count, other.Values.Count);
                }

                int result = 0;
                for (int i = 0; i < attribCount; i++)
                {
                    if ((result = _values[i].CompareTo(other._values[i])) != 0)
                    {
                        return(result);
                    }
                }
                if (countNotEquals)
                {
                    if (_values.Count < other._values.Count)
                    {
                        return(-1);
                    }
                    return(1);
                }
                return(result);
            }
            return(typeRule);
        }
예제 #2
0
        public int CompareTo(object obj)
        {
            IJsonValue secondJsonValue = obj as IJsonValue;

            if (secondJsonValue == null)
            {
                throw new ArgumentException("Object must be of type IJSONValue");
            }

            if (obj is EmbeddedList)
            {
                return(EmbeddedHelper.Compare(this, obj as EmbeddedList));
            }

            int typeRule = DataType.CompareTo(secondJsonValue.DataType);

            if (typeRule != 0)
            {
                return(typeRule);
            }
            return(Equals(obj) ? 0 : int.MinValue);
        }
예제 #3
0
        public int CompareTo(Tag other)
        {
            if (other == null)
            {
                return(1);
            }

            int result = 0;

            result = m_Checked.CompareTo(other.m_Checked);
            if (result != 0)
            {
                return(result);
            }

            result = m_Enabled.CompareTo(other.m_Enabled);
            if (result != 0)
            {
                return(result);
            }

            result = m_Visible.CompareTo(other.m_Visible);
            if (result != 0)
            {
                return(result);
            }

            result = m_ValueSelect1.CompareTo(other.m_ValueSelect1);
            if (result != 0)
            {
                return(result);
            }

            result = m_ValueSelect2.CompareTo(other.m_ValueSelect2);
            if (result != 0)
            {
                return(result);
            }

            result = ChannelId.CompareTo(other.ChannelId);
            if (result != 0)
            {
                return(result);
            }

            result = DataBlockId.CompareTo(other.DataBlockId);
            if (result != 0)
            {
                return(result);
            }

            result = DeviceId.CompareTo(other.DeviceId);
            if (result != 0)
            {
                return(result);
            }

            result = DataType.CompareTo(other.DataType);
            if (result != 0)
            {
                return(result);
            }

            result = Address.CompareTo(other.Address);
            if (result != 0)
            {
                return(result);
            }

            result = TagName.CompareTo(other.TagName);
            if (result != 0)
            {
                return(result);
            }

            result = TagId.CompareTo(other.TagId);
            if (result != 0)
            {
                return(result);
            }

            result = Timestamp.CompareTo(other.Timestamp);
            if (result != 0)
            {
                return(result);
            }

            result = Description.CompareTo(other.Description);
            if (result != 0)
            {
                return(result);
            }

            return(result);
        }