Search Results for

    Show / Hide Table of Contents
    View Source

    Class SemVersion

    A semantic version implementation. Conforms to v2.0.0 of http://semver.org/

    Inheritance
    System.Object
    Namespace: Umbraco.Cms.Core.Semver
    Assembly: Umbraco.Core.dll
    Syntax
    public sealed class SemVersion : IComparable<SemVersion>

    Constructors

    View Source

    SemVersion(Int32, Int32, Int32, String, String)

    Initializes a new instance of the SemVersion class.

    Declaration
    public SemVersion(int major, int minor = 0, int patch = 0, string prerelease = "", string build = "")
    Parameters
    Type Name Description
    System.Int32 major

    The major version.

    System.Int32 minor

    The minor version.

    System.Int32 patch

    The patch version.

    System.String prerelease

    The prerelease version (eg. "alpha").

    System.String build

    The build eg ("nightly.232").

    View Source

    SemVersion(Version)

    Initializes a new instance of the SemVersion class.

    Declaration
    public SemVersion(Version version)
    Parameters
    Type Name Description
    Version version

    The that is used to initialize the Major, Minor, Patch and Build properties.

    Properties

    View Source

    Build

    Gets the build version.

    Declaration
    public string Build { get; }
    Property Value
    Type Description
    System.String

    The build version.

    View Source

    Major

    Gets the major version.

    Declaration
    public int Major { get; }
    Property Value
    Type Description
    System.Int32

    The major version.

    View Source

    Minor

    Gets the minor version.

    Declaration
    public int Minor { get; }
    Property Value
    Type Description
    System.Int32

    The minor version.

    View Source

    Patch

    Gets the patch version.

    Declaration
    public int Patch { get; }
    Property Value
    Type Description
    System.Int32

    The patch version.

    View Source

    Prerelease

    Gets the pre-release version.

    Declaration
    public string Prerelease { get; }
    Property Value
    Type Description
    System.String

    The pre-release version.

    Methods

    View Source

    Change(Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, String, String)

    Make a copy of the current instance with optional altered fields.

    Declaration
    public SemVersion Change(int? major = null, int? minor = null, int? patch = null, string prerelease = null, string build = null)
    Parameters
    Type Name Description
    System.Nullable<System.Int32> major

    The major version.

    System.Nullable<System.Int32> minor

    The minor version.

    System.Nullable<System.Int32> patch

    The patch version.

    System.String prerelease

    The prerelease text.

    System.String build

    The build text.

    Returns
    Type Description
    SemVersion

    The new version object.

    View Source

    Compare(SemVersion, SemVersion)

    Compares the specified versions.

    Declaration
    public static int Compare(SemVersion versionA, SemVersion versionB)
    Parameters
    Type Name Description
    SemVersion versionA

    The version to compare to.

    SemVersion versionB

    The version to compare against.

    Returns
    Type Description
    System.Int32

    If versionA < versionB < 0, if versionA > versionB > 0, if versionA is equal to versionB 0.

    View Source

    CompareByPrecedence(SemVersion)

    Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.

    Declaration
    public int CompareByPrecedence(SemVersion other)
    Parameters
    Type Name Description
    SemVersion other

    The semantic version.

    Returns
    Type Description
    System.Int32

    A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the version precedence. Zero This instance has the same precedence as other. i Greater than zero This instance has creater precedence as other.

    View Source

    CompareTo(Object)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

    Declaration
    public int CompareTo(object obj)
    Parameters
    Type Name Description
    System.Object obj

    An object to compare with this instance.

    Returns
    Type Description
    System.Int32

    A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj. i Greater than zero This instance follows obj in the sort order.

    View Source

    CompareTo(SemVersion)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

    Declaration
    public int CompareTo(SemVersion other)
    Parameters
    Type Name Description
    SemVersion other

    An object to compare with this instance.

    Returns
    Type Description
    System.Int32

    A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other. i Greater than zero This instance follows other in the sort order.

    View Source

    Equals(Object)

    Determines whether the specified is equal to this instance.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj

    The to compare with this instance.

    Returns
    Type Description
    System.Boolean

    true if the specified is equal to this instance; otherwise, false.

    View Source

    Equals(SemVersion, SemVersion)

    Tests the specified versions for equality.

    Declaration
    public static bool Equals(SemVersion versionA, SemVersion versionB)
    Parameters
    Type Name Description
    SemVersion versionA

    The first version.

    SemVersion versionB

    The second version.

    Returns
    Type Description
    System.Boolean

    If versionA is equal to versionB true, else false.

    View Source

    GetHashCode()

    Returns a hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32

    A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

    View Source

    Parse(String, Boolean)

    Parses the specified string to a semantic version.

    Declaration
    public static SemVersion Parse(string version, bool strict = false)
    Parameters
    Type Name Description
    System.String version

    The version string.

    System.Boolean strict

    If set to true minor and patch version are required, else they default to 0.

    Returns
    Type Description
    SemVersion

    The SemVersion object.

    View Source

    PrecedenceMatches(SemVersion)

    Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.

    Declaration
    public bool PrecedenceMatches(SemVersion other)
    Parameters
    Type Name Description
    SemVersion other

    The semantic version.

    Returns
    Type Description
    System.Boolean

    true if the version precedence matches.

    View Source

    ToString()

    Returns a that represents this instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    A that represents this instance.

    View Source

    TryParse(String, out SemVersion, Boolean)

    Parses the specified string to a semantic version.

    Declaration
    public static bool TryParse(string version, out SemVersion semver, bool strict = false)
    Parameters
    Type Name Description
    System.String version

    The version string.

    SemVersion semver

    When the method returns, contains a SemVersion instance equivalent to the version string passed in, if the version string was valid, or null if the version string was not valid.

    System.Boolean strict

    If set to true minor and patch version are required, else they default to 0.

    Returns
    Type Description
    System.Boolean

    False when a invalid version string is passed, otherwise true.

    Operators

    View Source

    Equality(SemVersion, SemVersion)

    The override of the equals operator.

    Declaration
    public static bool operator ==(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    System.Boolean

    If left is equal to right true, else false.

    View Source

    GreaterThan(SemVersion, SemVersion)

    The override of the greater operator.

    Declaration
    public static bool operator>(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    System.Boolean

    If left is greater than right true, else false.

    View Source

    GreaterThanOrEqual(SemVersion, SemVersion)

    The override of the greater than or equal operator.

    Declaration
    public static bool operator >=(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    System.Boolean

    If left is greater than or equal to right true, else false.

    View Source

    Implicit(String to SemVersion)

    Implicit conversion from string to SemVersion.

    Declaration
    public static implicit operator SemVersion(string version)
    Parameters
    Type Name Description
    System.String version

    The semantic version.

    Returns
    Type Description
    SemVersion

    The SemVersion object.

    View Source

    Inequality(SemVersion, SemVersion)

    The override of the un-equal operator.

    Declaration
    public static bool operator !=(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    System.Boolean

    If left is not equal to right true, else false.

    View Source

    LessThan(SemVersion, SemVersion)

    The override of the less operator.

    Declaration
    public static bool operator <(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    System.Boolean

    If left is less than right true, else false.

    View Source

    LessThanOrEqual(SemVersion, SemVersion)

    The override of the less than or equal operator.

    Declaration
    public static bool operator <=(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    System.Boolean

    If left is less than or equal to right true, else false.

    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • SemVersion(Int32, Int32, Int32, String, String)
      • SemVersion(Version)
    • Properties
      • Build
      • Major
      • Minor
      • Patch
      • Prerelease
    • Methods
      • Change(Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, String, String)
      • Compare(SemVersion, SemVersion)
      • CompareByPrecedence(SemVersion)
      • CompareTo(Object)
      • CompareTo(SemVersion)
      • Equals(Object)
      • Equals(SemVersion, SemVersion)
      • GetHashCode()
      • Parse(String, Boolean)
      • PrecedenceMatches(SemVersion)
      • ToString()
      • TryParse(String, out SemVersion, Boolean)
    • Operators
      • Equality(SemVersion, SemVersion)
      • GreaterThan(SemVersion, SemVersion)
      • GreaterThanOrEqual(SemVersion, SemVersion)
      • Implicit(String to SemVersion)
      • Inequality(SemVersion, SemVersion)
      • LessThan(SemVersion, SemVersion)
      • LessThanOrEqual(SemVersion, SemVersion)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX