Exemplo n.º 1
0
        private Range(Comparator[][] comparatorSets,  bool loose, string source)
        {
            _set = comparatorSets;
            _loose = loose;
            _source = source;
            _loose = loose;

            _source = string.Join("||", _set.Select(comps => string.Join(" ", comps.Select(c => c.ToString()))));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tries to convert the specified string representation of a comparator to its
        /// <see cref="T:SemanticVersioning.Comparator"/> equivalent. A return value indicates whether the conversion
        /// succeeded or failed.
        /// </summary>
        /// <param name="source">The string representation of the range</param>
        /// <param name="comparator">
        /// When this method returns, contains a <see cref="T:SemanticVersioning.Comparator"/> if the conversion succeeded.
        /// </param>
        /// <param name="loose">Whether to use loose mode or not</param>
        /// <returns>true if <paramref name="source"/> was converted successfully; otherwise, false.</returns>
        public static bool TryParse(string source, out Comparator comparator, bool loose = false)
        {
            var regex = loose ? Re.ComparatorLoose : Re.Comparator;
            var match = regex.Match(source);

            if (!match.Success)
            {
                comparator = null;
                return false;
            }
            comparator = Parse(match, source, loose);
            return true;
        }