Octopus.Client.Model.SemanticVersion.Parse C# (CSharp) Method

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
        public static SemanticVersion Parse(string value, bool preserveMissingComponents = false)
        {
            if (String.IsNullOrEmpty(value))
            {
                throw new ArgumentException("Value cannot be null or an empty string", nameof(value));
            }

            SemanticVersion ver = null;
            if (!TryParse(value, out ver, preserveMissingComponents))
            {
                throw new ArgumentException($"'{value}' is not a valid version string", nameof(value));
            }

            return ver;
        }

Usage Example

Exemplo n.º 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;
     }
 }
All Usage Examples Of Octopus.Client.Model.SemanticVersion::Parse