Example #1
0
        public int CompareTo(IndexValue other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var typeComparison = Type.CompareTo(other.Type);

            if (typeComparison != 0)
            {
                return(typeComparison);
            }
            switch (Type)
            {
            case IndexValueType.String:
                return(string.Compare(StringValue, other.StringValue, StringComparison.Ordinal));

            case IndexValueType.StringArray:
                return(string.Compare(ValueAsString, other.ValueAsString, StringComparison.Ordinal));

            case IndexValueType.Bool:
                return(BooleanValue.CompareTo(other.BooleanValue));

            case IndexValueType.Int:
                return(IntegerValue.CompareTo(other.IntegerValue));

            case IndexValueType.IntArray:
                return(string.Compare(ValueAsString, other.ValueAsString, StringComparison.Ordinal));

            case IndexValueType.Long:
                return(LongValue.CompareTo(other.LongValue));

            case IndexValueType.Float:
                return(SingleValue.CompareTo(other.SingleValue));

            case IndexValueType.Double:
                return(DoubleValue.CompareTo(other.DoubleValue));

            case IndexValueType.DateTime:
                return(DateTimeValue.CompareTo(other.DateTimeValue));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }