示例#1
0
        internal unsafe static int CompareBytes(Guid x, Guid y)
        {
            Guid *px = &x;
            Guid *py = &y;

            return(RuleUtil.CompareBytes((byte *)px, (byte *)py, sizeof(Guid)));
        }
示例#2
0
        internal unsafe static int CompareBytes(long x, long y)
        {
            long *px = &x;
            long *py = &y;

            return(RuleUtil.CompareBytes((byte *)px, (byte *)py, 8));
        }
示例#3
0
        internal unsafe static int CompareBytes(byte[] x, byte[] y)
        {
            int len = Math.Min(x.Length, y.Length);

            fixed(byte *ptr = x)
            {
                fixed(byte *ptr2 = y)
                {
                    int num = RuleUtil.CompareBytes(ptr, ptr2, len);
                    int result;

                    if (num != 0)
                    {
                        result = num;
                    }
                    else
                    {
                        result = x.Length.CompareTo(y.Length);
                    }
                    return(result);
                }
            }
        }
示例#4
0
        internal static int?CompareValue(CultureInfo cultureInfo, PropTag tag, object x, object y)
        {
            int?     result   = null;
            PropType propType = tag.ValueType();

            if (propType <= PropType.String)
            {
                switch (propType)
                {
                case PropType.Short:
                    result = new int?(((short)x).CompareTo((short)y));
                    break;

                case PropType.Int:
                    result = new int?(((int)x).CompareTo((int)y));
                    break;

                case PropType.Float:
                    result = new int?(((float)x).CompareTo((float)y));
                    break;

                case PropType.Double:
                case PropType.AppTime:
                    result = new int?(((double)x).CompareTo((double)y));
                    break;

                case PropType.Currency:
                    result = new int?(((long)x).CompareTo((long)y));
                    break;

                case (PropType)8:
                case (PropType)9:
                case PropType.Error:
                    break;

                case PropType.Boolean:
                    result = new int?(((bool)x).CompareTo((bool)y));
                    break;

                default:
                    if (propType != PropType.Long)
                    {
                        switch (propType)
                        {
                        case PropType.AnsiString:
                        case PropType.String:
                            result = new int?(cultureInfo.CompareInfo.Compare((string)x, (string)y, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth));
                            break;
                        }
                    }
                    else if (RuleUtil.IsLongID(tag))
                    {
                        result = new int?(RuleUtil.CompareBytes((long)x, (long)y));
                    }
                    else
                    {
                        result = new int?(((long)x).CompareTo((long)y));
                    }
                    break;
                }
            }
            else if (propType != PropType.SysTime)
            {
                if (propType != PropType.Guid)
                {
                    if (propType == PropType.Binary)
                    {
                        byte[] x2 = (byte[])x;
                        byte[] y2 = (byte[])y;
                        if (RuleUtil.IsEntryIdProp(tag) && RuleUtil.EqualsEntryId(x2, y2))
                        {
                            result = new int?(0);
                        }
                        else
                        {
                            result = new int?(RuleUtil.CompareBytes(x2, y2));
                        }
                    }
                }
                else
                {
                    result = new int?(RuleUtil.CompareBytes((Guid)x, (Guid)y));
                }
            }
            else
            {
                result = new int?((x is ExDateTime) ? ((DateTime)((ExDateTime)x).ToUtc()).CompareTo((DateTime)y) : ((DateTime)x).CompareTo((DateTime)y));
            }
            return(result);
        }