예제 #1
0
        public static Semver Parse(string value)
        {
            value = (value ?? "").Trim();
            var tokens = SemverTokenizer.Match(value ?? "");

            if (!tokens.Success)
            {
                throw new FormatException("Invalid Semantic version");
            }

            var semver = new Semver(
                int.Parse(tokens.Groups["major"].Value),
                int.Parse(tokens.Groups["minor"].Value),
                int.Parse(tokens.Groups["patch"].Value),
                tokens.Groups["prerelease"].Value,
                tokens.Groups["buildmetadata"].Value
                );

            return(semver);
        }
예제 #2
0
 public static bool IsValidSemver(string version)
 {
     return(SemverTokenizer.IsMatch(version ?? ""));
 }