Exemple #1
0
        private static bool IsVersionSupported(string range)
        {
            var parser    = new RangeParser();
            var predicate = parser.Evaluate(range);
            var v         = Pcap.LibpcapVersion;
            var version   = new SemanticVersion(v.Major, v.Minor, Math.Max(v.Build, 0));

            return(predicate(version));
        }
Exemple #2
0
        private Func <SemanticVersion, bool> GetExlusiveVersionComparer(string range)
        {
            // Range should be one of the following formats: "(x.y.z, a.b.c)", "(x.y.z,)", "(, x.y.z)"
            Regex r     = new Regex(@"\((?<low>.*)?,(?<high>.*)?\)", RegexOptions.Compiled);
            var   match = r.Match(range);

            if (!match.Success)
            {
                Log.Error($"Could not find semantic version comparer for version range {range}");
                return(v => false);
            }

            string low  = match.Groups["low"].Value.Trim();
            string high = match.Groups["high"].Value.Trim();

            string expression = string.Empty;

            if (!string.IsNullOrEmpty(low))
            {
                expression = $"> {low}";
            }

            if (!string.IsNullOrEmpty(high))
            {
                if (string.IsNullOrEmpty(expression))
                {
                    expression = $"< {high}";
                }
                else
                {
                    expression += $" && < {high}";
                }
            }

            RangeParser parser = new RangeParser();

            return(parser.Evaluate(expression));
        }