Definitto 1.1.0
The essential defines manager for the Unity game engine. API reference.
Public Member Functions | Static Public Member Functions | Properties | List of all members
Turbanov.Toolworks.Definitto.SemVersion Class Reference

A semantic version implementation. Conforms to v2.0.0 of http://semver.org/ Original source by Max Hauser: https://github.com/maxhauser/semver More...

Inheritance diagram for Turbanov.Toolworks.Definitto.SemVersion:
Inheritance graph
[legend]
Collaboration diagram for Turbanov.Toolworks.Definitto.SemVersion:
Collaboration graph
[legend]

Public Member Functions

 SemVersion (int major, int minor=0, int patch=0, string prerelease="", string build="")
 Initializes a new instance of the SemVersion class. More...
 
 SemVersion (Version version)
 Initializes a new instance of the SemVersion class. More...
 
SemVersion Change (int? major=null, int? minor=null, int? patch=null, string prerelease=null, string build=null)
 Make a copy of the current instance with optional altered fields. More...
 
override string ToString ()
 Returns a System.String that represents this instance. More...
 
int CompareTo (object obj)
 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. More...
 
int CompareTo (SemVersion other)
 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. More...
 
bool PrecedenceMatches (SemVersion other)
 Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information. More...
 
int CompareByPrecedence (SemVersion other)
 Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information. More...
 
override bool Equals (object obj)
 Determines whether the specified System.Object is equal to this instance. More...
 
override int GetHashCode ()
 Returns a hash code for this instance. More...
 
void GetObjectData (SerializationInfo info, StreamingContext context)
 Get the object data. More...
 

Static Public Member Functions

static SemVersion Parse (string version, bool strict=false)
 Parses the specified string to a semantic version. More...
 
static bool TryParse (string version, out SemVersion semver, bool strict=false)
 Parses the specified string to a semantic version. More...
 
static bool Equals (SemVersion versionA, SemVersion versionB)
 Tests the specified versions for equality. More...
 
static int Compare (SemVersion versionA, SemVersion versionB)
 Compares the specified versions. More...
 
static implicit operator SemVersion (string version)
 Implicit conversion from string to SemVersion. More...
 
static bool operator== (SemVersion left, SemVersion right)
 The override of the equals operator. More...
 
static bool operator!= (SemVersion left, SemVersion right)
 The override of the un-equal operator. More...
 
static bool operator> (SemVersion left, SemVersion right)
 The override of the greater operator. More...
 
static bool operator>= (SemVersion left, SemVersion right)
 The override of the greater than or equal operator. More...
 
static bool operator< (SemVersion left, SemVersion right)
 The override of the less operator. More...
 
static bool operator<= (SemVersion left, SemVersion right)
 The override of the less than or equal operator. More...
 

Properties

int Major [get]
 Gets the major version. More...
 
int Minor [get]
 Gets the minor version. More...
 
int Patch [get]
 Gets the patch version. More...
 
string Prerelease [get]
 Gets the pre-release version. More...
 
string Build [get]
 Gets the build version. More...
 

Detailed Description

A semantic version implementation. Conforms to v2.0.0 of http://semver.org/ Original source by Max Hauser: https://github.com/maxhauser/semver

Constructor & Destructor Documentation

◆ SemVersion() [1/2]

Turbanov.Toolworks.Definitto.SemVersion.SemVersion ( int  major,
int  minor = 0,
int  patch = 0,
string  prerelease = "",
string  build = "" 
)

Initializes a new instance of the SemVersion class.

Parameters
majorThe major version.
minorThe minor version.
patchThe patch version.
prereleaseThe prerelease version (eg. "alpha").
buildThe build eg ("nightly.232").

◆ SemVersion() [2/2]

Turbanov.Toolworks.Definitto.SemVersion.SemVersion ( Version  version)

Initializes a new instance of the SemVersion class.

Parameters
versionThe System.Version that is used to initialize the Major, Minor, Patch and Build properties.

Member Function Documentation

◆ Change()

SemVersion Turbanov.Toolworks.Definitto.SemVersion.Change ( int?  major = null,
int?  minor = null,
int?  patch = null,
string  prerelease = null,
string  build = null 
)

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

Parameters
majorThe major version.
minorThe minor version.
patchThe patch version.
prereleaseThe prerelease text.
buildThe build text.
Returns
The new version object.

◆ Compare()

static int Turbanov.Toolworks.Definitto.SemVersion.Compare ( SemVersion  versionA,
SemVersion  versionB 
)
static

Compares the specified versions.

Parameters
versionAThe version to compare to.
versionBThe version to compare against.
Returns
If versionA < versionB < 0, if versionA > versionB > 0, if versionA is equal to versionB 0.

◆ CompareByPrecedence()

int Turbanov.Toolworks.Definitto.SemVersion.CompareByPrecedence ( SemVersion  other)

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

Parameters
otherThe semantic version.
Returns
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 .

◆ CompareTo() [1/2]

int Turbanov.Toolworks.Definitto.SemVersion.CompareTo ( object  obj)

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.

Parameters
objAn object to compare with this instance.
Returns
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.

◆ CompareTo() [2/2]

int Turbanov.Toolworks.Definitto.SemVersion.CompareTo ( SemVersion  other)

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.

Parameters
otherAn object to compare with this instance.
Returns
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.

◆ Equals() [1/2]

static bool Turbanov.Toolworks.Definitto.SemVersion.Equals ( SemVersion  versionA,
SemVersion  versionB 
)
static

Tests the specified versions for equality.

Parameters
versionAThe first version.
versionBThe second version.
Returns
If versionA is equal to versionB true, else false.

◆ Equals() [2/2]

override bool Turbanov.Toolworks.Definitto.SemVersion.Equals ( object  obj)

Determines whether the specified System.Object is equal to this instance.

Parameters
objThe System.Object to compare with this instance.
Returns
true if the specified System.Object is equal to this instance; otherwise, false.

◆ GetHashCode()

override int Turbanov.Toolworks.Definitto.SemVersion.GetHashCode ( )

Returns a hash code for this instance.

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

◆ GetObjectData()

void Turbanov.Toolworks.Definitto.SemVersion.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)

Get the object data.

Parameters
infoSerialization info.
contextStreaming context.

◆ operator SemVersion()

static implicit Turbanov.Toolworks.Definitto.SemVersion.operator SemVersion ( string  version)
static

Implicit conversion from string to SemVersion.

Parameters
versionThe semantic version.
Returns
The SemVersion object.

◆ operator!=()

static bool Turbanov.Toolworks.Definitto.SemVersion.operator!= ( SemVersion  left,
SemVersion  right 
)
static

The override of the un-equal operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is not equal to right true, else false.

◆ operator<()

static bool Turbanov.Toolworks.Definitto.SemVersion.operator< ( SemVersion  left,
SemVersion  right 
)
static

The override of the less operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is less than right true, else false.

◆ operator<=()

static bool Turbanov.Toolworks.Definitto.SemVersion.operator<= ( SemVersion  left,
SemVersion  right 
)
static

The override of the less than or equal operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is less than or equal to right true, else false.

◆ operator==()

static bool Turbanov.Toolworks.Definitto.SemVersion.operator== ( SemVersion  left,
SemVersion  right 
)
static

The override of the equals operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is equal to right true, else false.

◆ operator>()

static bool Turbanov.Toolworks.Definitto.SemVersion.operator> ( SemVersion  left,
SemVersion  right 
)
static

The override of the greater operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is greater than right true, else false.

◆ operator>=()

static bool Turbanov.Toolworks.Definitto.SemVersion.operator>= ( SemVersion  left,
SemVersion  right 
)
static

The override of the greater than or equal operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is greater than or equal to right true, else false.

◆ Parse()

static SemVersion Turbanov.Toolworks.Definitto.SemVersion.Parse ( string  version,
bool  strict = false 
)
static

Parses the specified string to a semantic version.

Parameters
versionThe version string.
strictIf set to true minor and patch version are required, else they default to 0.
Returns
The SemVersion object.
Exceptions
System.InvalidOperationExceptionWhen a invalid version string is passed.

◆ PrecedenceMatches()

bool Turbanov.Toolworks.Definitto.SemVersion.PrecedenceMatches ( SemVersion  other)

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

Parameters
otherThe semantic version.
Returns
true if the version precedence matches.

◆ ToString()

override string Turbanov.Toolworks.Definitto.SemVersion.ToString ( )

Returns a System.String that represents this instance.

Returns
A System.String that represents this instance.

◆ TryParse()

static bool Turbanov.Toolworks.Definitto.SemVersion.TryParse ( string  version,
out SemVersion  semver,
bool  strict = false 
)
static

Parses the specified string to a semantic version.

Parameters
versionThe version string.
semverWhen 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.
strictIf set to true minor and patch version are required, else they default to 0.
Returns
False when a invalid version string is passed, otherwise true.

Property Documentation

◆ Build

string Turbanov.Toolworks.Definitto.SemVersion.Build
get

Gets the build version.

The build version.

◆ Major

int Turbanov.Toolworks.Definitto.SemVersion.Major
get

Gets the major version.

The major version.

◆ Minor

int Turbanov.Toolworks.Definitto.SemVersion.Minor
get

Gets the minor version.

The minor version.

◆ Patch

int Turbanov.Toolworks.Definitto.SemVersion.Patch
get

Gets the patch version.

The patch version.

◆ Prerelease

string Turbanov.Toolworks.Definitto.SemVersion.Prerelease
get

Gets the pre-release version.

The pre-release version.


The documentation for this class was generated from the following file: