private static int CompareNumericDateVariantTypes(DataTypeCode x, DataTypeCode y, bool throwExceptionOnComparisonFailure)
        {
            switch (x)
            {
            case DataTypeCode.DateTime:
                return(1);

            case DataTypeCode.Double:
                if (ComparerUtility.IsLessThanReal(y))
                {
                    return(1);
                }
                return(-1);

            case DataTypeCode.Decimal:
                if (ComparerUtility.IsLessThanCurrency(y))
                {
                    return(1);
                }
                return(-1);

            case DataTypeCode.Int64:
                if (ComparerUtility.IsLessThanInt64(y))
                {
                    return(1);
                }
                return(-1);

            case DataTypeCode.Int32:
                return(-1);

            default:
                if (throwExceptionOnComparisonFailure)
                {
                    throw new CommonDataComparerException(x.ToString(), y.ToString());
                }
                return(-1);
            }
        }
 private static int CompareToNonNumericVariantTypes(DataTypeCode xDataType, DataTypeCode yDataType, object x, object y, bool throwExceptionOnComparisonFailure)
 {
     if (ComparerUtility.IsNumericDateVariant(xDataType) && ComparerUtility.IsNonNumericVariant(yDataType))
     {
         return(-1);
     }
     if (ComparerUtility.IsNonNumericVariant(xDataType) && ComparerUtility.IsNumericDateVariant(yDataType))
     {
         return(1);
     }
     if (xDataType == DataTypeCode.String && yDataType == DataTypeCode.Boolean)
     {
         return(-1);
     }
     if (xDataType == DataTypeCode.Boolean && yDataType == DataTypeCode.String)
     {
         return(1);
     }
     if (throwExceptionOnComparisonFailure)
     {
         throw new CommonDataComparerException(x.ToString(), y.ToString());
     }
     return(-1);
 }
        private int InternalCompareTo(object x, object y, bool throwExceptionOnComparisonFailure)
        {
            string text  = x as string;
            string text2 = y as string;

            if (text != null && text2 != null)
            {
                return(m_compareInfo.Compare(text, text2, m_compareOptions));
            }
            DataTypeCode dataTypeCode  = ObjectSerializer.GetDataTypeCode(x);
            DataTypeCode dataTypeCode2 = ObjectSerializer.GetDataTypeCode(y);

            if (dataTypeCode == DataTypeCode.Empty && dataTypeCode2 == DataTypeCode.Empty)
            {
                return(0);
            }
            if (dataTypeCode == DataTypeCode.Empty)
            {
                if (m_nullsAsBlanks && ComparerUtility.IsNumericLessThanZero(y))
                {
                    return(1);
                }
                return(-1);
            }
            if (dataTypeCode2 == DataTypeCode.Empty)
            {
                if (m_nullsAsBlanks && ComparerUtility.IsNumericLessThanZero(x))
                {
                    return(-1);
                }
                return(1);
            }
            if (dataTypeCode != dataTypeCode2)
            {
                switch (ComparerUtility.GetCommonVariantConversionType(dataTypeCode, dataTypeCode2))
                {
                case DataTypeCode.Double:
                {
                    double num  = 0.0;
                    double num2 = 0.0;
                    if (dataTypeCode == DataTypeCode.DateTime)
                    {
                        num  = ((DateTime)x).ToOADate();
                        num2 = Convert.ToDouble(y, m_cultureInfo);
                    }
                    else if (dataTypeCode2 == DataTypeCode.DateTime)
                    {
                        num2 = ((DateTime)y).ToOADate();
                        num  = Convert.ToDouble(x, m_cultureInfo);
                    }
                    else
                    {
                        num  = Convert.ToDouble(x, m_cultureInfo);
                        num2 = Convert.ToDouble(y, m_cultureInfo);
                    }
                    int num3 = num.CompareTo(num2);
                    if (num3 == 0)
                    {
                        return(CompareNumericDateVariantTypes(dataTypeCode, dataTypeCode2, throwExceptionOnComparisonFailure));
                    }
                    return(num3);
                }

                case DataTypeCode.Decimal:
                {
                    decimal num4  = Convert.ToDecimal(x, m_cultureInfo);
                    decimal value = Convert.ToDecimal(y, m_cultureInfo);
                    int     num5  = num4.CompareTo(value);
                    if (num5 == 0)
                    {
                        return(CompareNumericDateVariantTypes(dataTypeCode, dataTypeCode2, throwExceptionOnComparisonFailure));
                    }
                    return(num5);
                }

                case DataTypeCode.Int64:
                {
                    long num6   = Convert.ToInt64(x, m_cultureInfo);
                    long value2 = Convert.ToInt64(y, m_cultureInfo);
                    int  num7   = num6.CompareTo(value2);
                    if (num7 == 0)
                    {
                        return(CompareNumericDateVariantTypes(dataTypeCode, dataTypeCode2, throwExceptionOnComparisonFailure));
                    }
                    return(num7);
                }

                case DataTypeCode.Unknown:
                    if (ComparerUtility.IsNonNumericVariant(dataTypeCode) || ComparerUtility.IsNonNumericVariant(dataTypeCode2))
                    {
                        return(CompareToNonNumericVariantTypes(dataTypeCode, dataTypeCode2, x, y, throwExceptionOnComparisonFailure));
                    }
                    break;
                }
            }
            ICustomComparable customComparable  = x as ICustomComparable;
            ICustomComparable customComparable2 = y as ICustomComparable;

            if (customComparable != null && customComparable2 != null)
            {
                return(customComparable.CompareTo(customComparable2, this));
            }
            IComparable left  = (IComparable)x;
            IComparable right = (IComparable)y;

            return(Compare(left, right, throwExceptionOnComparisonFailure));
        }