Пример #1
0
        public static bool?Overlaps(Session session, object[] a, SqlType[] ta, object[] b, SqlType[] tb)
        {
            if ((a == null) || (b == null))
            {
                return(null);
            }
            if ((a[0] == null) || (b[0] == null))
            {
                return(null);
            }
            if (a[1] == null)
            {
                a[1] = a[0];
            }
            if (b[1] == null)
            {
                b[1] = b[0];
            }
            SqlType combinedType = ta[0].GetCombinedType(tb[0], 0x29);

            a[0] = combinedType.CastToType(session, a[0], ta[0]);
            b[0] = combinedType.CastToType(session, b[0], tb[0]);
            if (ta[1].IsIntervalType())
            {
                a[1] = combinedType.Add(a[0], a[1], ta[0], ta[1]);
            }
            else
            {
                a[1] = combinedType.CastToType(session, a[1], ta[1]);
            }
            if (tb[1].IsIntervalType())
            {
                b[1] = combinedType.Add(b[0], b[1], tb[0], tb[1]);
            }
            else
            {
                b[1] = combinedType.CastToType(session, b[1], tb[1]);
            }
            if (combinedType.Compare(session, a[0], a[1], null, false) > 0)
            {
                object obj2 = a[0];
                a[0] = a[1];
                a[1] = obj2;
            }
            if (combinedType.Compare(session, b[0], b[1], null, false) > 0)
            {
                object obj3 = b[0];
                b[0] = b[1];
                b[1] = obj3;
            }
            if (combinedType.Compare(session, a[0], b[0], null, false) > 0)
            {
                a = b;
                b = a;
            }
            return(combinedType.Compare(session, a[1], b[0], null, false) > 0);
        }