Parse() public static method

Creates a NuGetVersion from a string representing the semantic version.
public static Parse ( string value, bool preserveMissingComponents = false ) : SemanticVersion
value string
preserveMissingComponents bool
return SemanticVersion
コード例 #1
0
 public void Default(string packageVersion)
 {
     try
     {
         SemanticVersion.Parse(packageVersion);
         defaultVersion = packageVersion;
     }
     catch (ArgumentException)
     {
         if (packageVersion.Contains(":"))
         {
             throw new ArgumentException("Invalid package version format. Use the package parameter if you need to specify the step name and version.");
         }
         throw;
     }
 }
コード例 #2
0
        public void Add(string stepNameOrPackageId, string packageReferenceName, string packageVersion)
        {
            // Double wild card == default value
            if (stepNameOrPackageId == WildCard && packageReferenceName == WildCard)
            {
                Default(packageVersion);
                return;
            }

            var key = new PackageKey(stepNameOrPackageId, packageReferenceName ?? WildCard);

            if (stepNameToVersion.TryGetValue(key, out var current))
            {
                var newVersion     = SemanticVersion.Parse(packageVersion);
                var currentVersion = SemanticVersion.Parse(current);
                if (newVersion < currentVersion)
                {
                    return;
                }
            }

            stepNameToVersion[key] = packageVersion;
        }