Beispiel #1
0
        public int NonConvertingCompare(BindingValue right)
        {
            if (ReferenceEquals(right, this))
            {
                return(0);
            }

            bool thisIsEmpty = (ReferenceEquals(this, Empty));

            if (ReferenceEquals(right, Empty))
            {
                // empty is less than all values
                return(thisIsEmpty ? 0 : 1);
            }

            int typeDifference = _nativeValueType - right._nativeValueType;

            if (typeDifference != 0)
            {
                // different types sort by type
                return(typeDifference);
            }

            switch (_nativeValueType)
            {
            case BindingValueType.Boolean:
                return(BoolValue.CompareTo(right.BoolValue));

            case BindingValueType.String:
                return(string.Compare(StringValue, right.StringValue, StringComparison.InvariantCulture));

            case BindingValueType.Double:
                return(DoubleValue.CompareTo(right.DoubleValue));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }