Exemplo n.º 1
0
        public int CompareTo(object obj)
        {
            if (obj is DateTime)
            {
                return(DateTimeValue.CompareTo((DateTime)obj));
            }
            CDateTimeEx dtex = (obj as CDateTimeEx);

            if (dtex != null)
            {
                return(DateTimeValue.CompareTo(dtex.DateTimeValue));
            }
            return(-1);
        }
Exemplo n.º 2
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();
            }
        }
        public int CompareTo(object obj)
        {
            var typedObj = (AllSupportedPropertyTypesObject)obj;
            int result   = string.Compare(StringValue, typedObj.StringValue);

            if (result == 0)
            {
                result = IntValue.CompareTo(typedObj.IntValue);
            }
            if (result == 0)
            {
                result = Nullable.Compare(NullableIntValue, typedObj.NullableIntValue);
            }

            if (result == 0)
            {
                result = DoubleValue.CompareTo(typedObj.DoubleValue);
            }

            if (result == 0)
            {
                result = Nullable.Compare(NullableDoubleValue, typedObj.NullableDoubleValue);
            }

            if (result == 0)
            {
                result = DateTimeValue.CompareTo(typedObj.DoubleValue);
            }

            if (result == 0)
            {
                result = Nullable.Compare(NullableDateTimeValue, typedObj.NullableDateTimeValue);
            }

            if (result == 0)
            {
                // TODO: this is more correctly done by using SequenceCompareTo()
                //       method but this is only available from Standard 2.1 onwards.
                //       Use basic custom implementation for backward compatibility.
                //result =  ByteArrayValue.SequenceEqual(typedObj.ByteArrayValue);
            }

            return(result);
        }