示例#1
0
            internal bool TryConstraint(out CompareFlag flag)
            {
                SkipLeading();
                flag = CompareFlag.None;
                while (!EOF && IsConstraint(_Current))
                {
                    if (_Current == MINOR)
                    {
                        flag = CompareFlag.MinorUplift;
                    }
                    else if (_Current == PATCH)
                    {
                        flag = CompareFlag.PatchUplift;
                    }
                    else if (_Current == EQUAL)
                    {
                        flag |= CompareFlag.Equals;
                    }
                    else if (_Current == GREATER)
                    {
                        flag |= CompareFlag.GreaterThan;
                    }
                    else if (_Current == LESS)
                    {
                        flag |= CompareFlag.LessThan;
                    }

                    Next();
                }
                return(flag != CompareFlag.None);
            }
示例#2
0
            internal void GetConstraint(out CompareFlag flag)
            {
                flag = CompareFlag.None;
                while (!EOF && IsConstraint(_Current))
                {
                    if (_Current == MINOR)
                    {
                        flag = CompareFlag.MinorUplift;
                    }
                    else if (_Current == PATCH)
                    {
                        flag = CompareFlag.PatchUplift;
                    }
                    else if (_Current == EQUAL)
                    {
                        flag |= CompareFlag.Equals;
                    }
                    else if (_Current == GREATER)
                    {
                        flag |= CompareFlag.GreaterThan;
                    }
                    else if (_Current == LESS)
                    {
                        flag |= CompareFlag.LessThan;
                    }

                    Next();
                }
            }
示例#3
0
 internal Constraint(int major, int minor, int patch, string prerelease, CompareFlag flag)
 {
     _Flag       = flag == CompareFlag.None ? CompareFlag.Equals : flag;
     _Major      = major;
     _Minor      = minor;
     _Patch      = patch;
     _Prerelease = prerelease;
 }
        /// <summary>
        /// 指示指定的值是不是在指定的范围内。
        /// </summary>
        /// <typeparam name="T">要测试的类型。</typeparam>
        /// <param name="value">要测试的值。</param>
        /// <param name="minValue">最小值。</param>
        /// <param name="maxValue">最大值。</param>
        /// <param name="compareFlag">比较标识,默认大于等于和小于等于。</param>
        /// <returns></returns>
        public static bool IsRange <T>(this T value, T minValue, T maxValue, CompareFlag compareFlag = CompareFlag.GreaterEqualAndLessEqual) where T : struct, IComparable
        {
            bool result = false;

            switch (compareFlag)
            {
            case CompareFlag.GreaterAndLess:
                result = IsGreater(value, minValue) && IsLess(value, maxValue);
                break;

            case CompareFlag.GreaterEqualAndLessEqual:
                result = IsGreaterEqual(value, maxValue) && IsLessEqual(value, maxValue);
                break;

            case CompareFlag.GreaterAndLessEqual:
                result = IsGreater(value, minValue) && IsLessEqual(value, maxValue);
                break;

            case CompareFlag.GreaterEqualAndLess:
                result = IsGreaterEqual(value, maxValue) && IsLess(value, maxValue);
                break;
            }
            return(result);
        }