Class VersionResult
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Represents different representations of a version scheme in a consistent way.
public class VersionResult
- Inheritance
-
VersionResult
Examples
The following example demonstrates how to use
using System;
using Cuemon.Reflection;
namespace MyApp.Examples;
public class VersionResultExample
{
public void Demonstrate()
{
// Numerical version (parsable to System.Version)
var numeric = new VersionResult("1.2.3.4");
Console.WriteLine($"Value: {numeric.Value}");
Console.WriteLine($"HasAlphanumericVersion: {numeric.HasAlphanumericVersion}");
Console.WriteLine($"IsSemanticVersion: {numeric.IsSemanticVersion()}");
// Semantic/alphanumeric version (not a pure numerical version)
var semantic = new VersionResult("2.0.0-beta.1");
Console.WriteLine($"\nValue: {semantic.Value}");
Console.WriteLine($"HasAlphanumericVersion: {semantic.HasAlphanumericVersion}");
Console.WriteLine($"IsSemanticVersion: {semantic.IsSemanticVersion()}");
// Static helper check
var check = VersionResult.IsSemanticVersion("3.0.0-rc.1");
Console.WriteLine($"\nIs '3.0.0-rc.1' semantic? {check}");
}
}
Constructors
VersionResult(string)
Initializes a new instance of the VersionResult class.
public VersionResult(string alphanumericVersion)
Parameters
VersionResult(Version)
Initializes a new instance of the VersionResult class.
public VersionResult(Version version)
Parameters
Exceptions
- ArgumentNullException
versioncannot be null.
Properties
AlphanumericVersion
Gets the alphanumeric version assigned to this instance.
public string AlphanumericVersion { get; }
Property Value
- string
The alphanumeric version assigned to this instance.
HasAlphanumericVersion
Gets a value indicating whether this instance has alphanumeric version assigned.
public bool HasAlphanumericVersion { get; }
Property Value
- bool
trueif this instance has alphanumeric version assigned; otherwise,false.
Value
Gets the value of the version passed to this object.
public string Value { get; }
Property Value
- string
The value of the version passed to this object.
Methods
IsSemanticVersion()
Determines whether this instance represents a semantic version.
public bool IsSemanticVersion()
Returns
- bool
trueif this instance represents a semantic version; otherwise,false.
IsSemanticVersion(string)
Determines whether this instance represents a semantic version.
public static bool IsSemanticVersion(string alphanumericVersion)
Parameters
Returns
- bool
trueif this instance represents a semantic version; otherwise,false.
ToString()
Returns a string that represents this instance.
public override string ToString()
Returns
ToVersion()
Converts this instance to an equivalent Version object.
public Version ToVersion()