Beispiel #1
0
        public bool Equals(object[] x, object[] y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }
            if (x.Length != y.Length)
            {
                return(false);
            }
            switch (x.Length)
            {
            case 1: return(eq(x[0], y[0]));

            case 2: return(eq(x[0], y[0]) && eq(x[1], y[1]));

            case 3: return(eq(x[0], y[0]) && eq(x[1], y[1]) && eq(x[2], y[2]));

            case 4: return(eq(x[0], y[0]) && eq(x[1], y[1]) && eq(x[2], y[2]) && eq(x[3], y[3]));

            default:
                for (int i = 0; i < x.Length; i++)
                {
                    if (!eq(x[i], y[i]))
                    {
                        return(false);
                    }
                }
                return(true);
            }

            bool eq(object a, object b)
            {
                var sameType = a.GetType() == b.GetType();

                if (sameType)
                {
                    // just Equals
                    return(a.Equals(b));
                }
                var sameHash = a.GetHashCode() == b.GetHashCode();

                if (sameHash)
                {
                    // this could be the same fixed-point value but different types
                    if (PivotDataHelper.IsConvertibleToDecimal(a.GetType()) &&
                        PivotDataHelper.IsConvertibleToDecimal(b.GetType()))
                    {
                        return(Convert.ToDecimal(a) == Convert.ToDecimal(b));
                    }
                }

                return(a.Equals(b));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Returns keys of specified dimensions
 /// </summary>
 /// <param name="dims">list of dimensions</param>
 /// <param name="dimSortComparers">list of comparers that should be used for sorting dimension keys</param>
 /// <returns>array of keys for specified dimensions</returns>
 public object[][] GetDimensionKeys(string[] dims, IComparer <object>[] dimSortComparers)
 {
     if (dims == null)
     {
         throw new ArgumentNullException("dims");
     }
     if (dimSortComparers == null)
     {
         // for backward compatibility, by default keys are sorted A-Z
         dimSortComparers = new IComparer <object> [dims.Length];
         for (int i = 0; i < dimSortComparers.Length; i++)
         {
             dimSortComparers[i] = NaturalSortKeyComparer.Instance;
         }
     }
     return(PivotDataHelper.GetDimensionKeys(this, dims, dimSortComparers));
 }