Ejemplo n.º 1
0
        public static bool TryParse(string value, out SemanticVersion version)
        {
            if (!string.IsNullOrEmpty(value))
            {
                var match = SemanticVersionStrictRegex.Match(value.Trim());

                Version versionValue;
                if (match.Success && Version.TryParse(match.Groups["Version"].Value, out versionValue))
                {
                    var normalizedVersion = NormalizeVersionValue(versionValue);
                    version = new SemanticVersion(normalizedVersion);
                    return true;
                }
            }

            version = null;
            return false;
        }
Ejemplo n.º 2
0
        public static int Compare(SemanticVersion x, SemanticVersion y)
        {
            if (ReferenceEquals(x, null) && ReferenceEquals(y, null))
                return 0;

            if (ReferenceEquals(y, null))
                return 1;

            if (ReferenceEquals(x, null))
                return -1;

            var result = x.Major.CompareTo(y.Major);
            if (result != 0)
                return result;

            result = x.Minor.CompareTo(y.Minor);
            if (result != 0)
                return result;

            result = x.Patch.CompareTo(y.Patch);

            return result;
        }