コード例 #1
0
ファイル: Real.cs プロジェクト: jdruin/F5Eagle
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region IComparer<string> Members
        public int Compare(
            string left,
            string right
            )
        {
            Result error = null;

            ListOps.GetElementsToCompare(
                interpreter, ascending, indexText, leftOnly, false,
                cultureInfo, ref left, ref right); /* throw */

            Number leftNumber = null;

            if ((Value.GetNumber(left, ValueFlags.AnyNumberAnyRadix, cultureInfo,
                                 ref leftNumber, ref error) == ReturnCode.Ok) &&
                leftNumber.ConvertTo(typeof(double)))
            {
                double leftDouble  = (double)leftNumber.Value;
                Number rightNumber = null;

                if ((Value.GetNumber(right, ValueFlags.AnyNumberAnyRadix, cultureInfo,
                                     ref rightNumber, ref error) == ReturnCode.Ok) &&
                    rightNumber.ConvertTo(typeof(double)))
                {
                    double rightDouble = (double)rightNumber.Value;

                    int result = LogicOps.Compare(leftDouble, rightDouble);

                    ListOps.UpdateDuplicateCount(this, duplicates, leftDouble.ToString(),
                                                 rightDouble.ToString(), unique, result, ref levels); /* throw */

                    return(result);
                }
            }

            if (error != null)
            {
                throw new ScriptException(error);
            }
            else
            {
                throw new ScriptException();
            }
        }
コード例 #2
0
ファイル: Integer.cs プロジェクト: jdruin/F5Eagle
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region IComparer<string> Members
        public int Compare(
            string left,
            string right
            )
        {
            Result error = null;

            ListOps.GetElementsToCompare(
                interpreter, ascending, indexText, leftOnly, false,
                cultureInfo, ref left, ref right); /* throw */

            long leftWide = 0;

            if (Value.GetWideInteger2(left, ValueFlags.AnyWideInteger, cultureInfo,
                                      ref leftWide, ref error) == ReturnCode.Ok)
            {
                long rightWide = 0;

                if (Value.GetWideInteger2(right, ValueFlags.AnyWideInteger, cultureInfo,
                                          ref rightWide, ref error) == ReturnCode.Ok)
                {
                    int result = LogicOps.Compare(leftWide, rightWide);

                    ListOps.UpdateDuplicateCount(this, duplicates, leftWide.ToString(),
                                                 rightWide.ToString(), unique, result, ref levels); /* throw */

                    return(result);
                }
            }

            if (error != null)
            {
                throw new ScriptException(error);
            }
            else
            {
                throw new ScriptException();
            }
        }
コード例 #3
0
ファイル: ScriptLocation.cs プロジェクト: jdruin/F5Eagle
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region IComparer<IScriptLocation> Members
        public int Compare(
            IScriptLocation x,
            IScriptLocation y
            )
        {
            if ((x == null) && (y == null))
            {
                return(0);
            }
            else if (x == null)
            {
                return(-1);
            }
            else if (y == null)
            {
                return(1);
            }
            else
            {
                int result = PathOps.CompareFileNames(x.FileName,
                                                      y.FileName);

                if (result != 0)
                {
                    return(result);
                }

                result = LogicOps.Compare(x.StartLine, y.StartLine);

                if (result != 0)
                {
                    return(result);
                }

                return(LogicOps.Compare(x.EndLine, y.EndLine));
            }
        }