示例#1
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));
            }

            return(JSONComparer.Compare(_value, DataType, NativeType, secondJsonValue.Value, secondJsonValue.DataType,
                                        secondJsonValue.NativeType, SortOrder.ASC));
        }
示例#2
0
        public override int CompareTo(object obj)
        {
            var eList = obj as EmbeddedList;

            if (eList != null)
            {
                return(EmbeddedHelper.Compare(this, eList));
            }
            var value = obj as AttributeValue;

            if (value != null)
            {
                switch (value.Type)
                {
                case AttributeValueType.Null:
                case AttributeValueType.All:
                    return(0);

                case AttributeValueType.Mask:
                    return(0 - value.CompareTo(this));

                case AttributeValueType.None:
                    return(-1);

                case AttributeValueType.Single:
                    if (value.DataType.Equals(FieldDataType.Null))
                    {
                        return(0);
                    }
                    return(_order == SortOrder.ASC ? int.MinValue : int.MaxValue);
                }
            }
            return(_order == SortOrder.ASC ? int.MinValue : int.MaxValue);

            //if (obj is NullValue || obj is AllValue)
            //    return 0;
            //AttributeValue value = obj as AttributeValue;
            //if (value != null && value.DataType.Equals(FieldDataType.Null))
            //    return 0;
            //return _order == SortOrder.ASC ? int.MinValue : int.MaxValue;
        }
示例#3
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);
        }