Table of Contents

VersionResult Class

Definition

Namespace
Cuemon.Reflection
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Reflection/VersionResult.cs

Represents different representations of a version scheme in a consistent way.

public class VersionResult
Inheritance
object
VersionResult

Examples

The following example demonstrates how to use to work with both numerical and semantic (alphanumeric) version strings.

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

Name Description
VersionResult(string)

Initializes a new instance of the VersionResult class.

VersionResult(Version)

Initializes a new instance of the VersionResult class.

Properties

Name Description
AlphanumericVersion

Gets the alphanumeric version assigned to this instance.

HasAlphanumericVersion

Gets a value indicating whether this instance has alphanumeric version assigned.

Value

Gets the value of the version passed to this object.

Methods

Name Description
IsSemanticVersion()

Determines whether this instance represents a semantic version.

IsSemanticVersion(string)

Determines whether this instance represents a semantic version.

ToString()

Returns a string that represents this instance.

ToVersion()

Converts this instance to an equivalent Version object.