Ejemplo n.º 1
0
        internal static readonly TCellComparer Instance = new TCellComparer();        //STATIC*

        #region IComparer Members

        public int Compare(object x, object y)
        {
            x = TExcelTypes.ConvertToAllowedObject(x, TBaseParsedToken.Dates1904);
            y = TExcelTypes.ConvertToAllowedObject(y, TBaseParsedToken.Dates1904);
            //null values go always at the bottom. (in ascending or descending order)
            if (x == null)
            {
                if (y == null)
                {
                    return(0);
                }
                return(1);
            }
            if (y == null)
            {
                return(-1);
            }

            if (x is TFlxFormulaErrorValue)
            {
                if (y is TFlxFormulaErrorValue)
                {
                    return(((int)x).CompareTo((int)y));
                }
                return(1);
            }
            if (y is TFlxFormulaErrorValue)
            {
                return(-1);
            }


            object Result = TBaseParsedToken.CompareValues(x, y);

            if (Result is int)
            {
                return((int)Result);
            }
            return(0);
        }