예제 #1
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);
        }