Table of Contents

Class ImplementationVersion

Namespace
ZeroInstall.Model
Assembly
ZeroInstall.Model.dll

Represents a version number consisting of dot-separated decimals and optional modifier strings.

[TypeConverter(typeof(StringConstructorConverter<ImplementationVersion>))]
[Serializable]
[Equatable]
public sealed class ImplementationVersion : IComparable<ImplementationVersion>, IEquatable<ImplementationVersion>
Inheritance
ImplementationVersion
Implements
Inherited Members

Remarks

This class is immutable and thread-safe.

This is the syntax for valid version strings:

Version := DottedList ("-" Modifier? DottedList?)*
  DottedList := (Integer ("." Integer)*)
  Modifier := "pre" | "rc" | "post"
If the string ContainsTemplateVariables(string) the entire string is stored verbatim and not parsed.

Constructors

ImplementationVersion(string)

Creates a new implementation version from a a string.

public ImplementationVersion(string value)

Parameters

value string

The string containing the version information.

Exceptions

FormatException

value is not a valid version string.

ImplementationVersion(Version)

Creates a new implementation version from a .NET Version.

public ImplementationVersion(Version version)

Parameters

version Version

The .NET Version to convert.

ImplementationVersion(VersionDottedList, params VersionPart[])

Creates a new implementation version.

public ImplementationVersion(VersionDottedList firstPart, params VersionPart[] additionalParts)

Parameters

firstPart VersionDottedList

The first part of the version number.

additionalParts VersionPart[]

All additional parts of the version number.

Properties

AdditionalParts

All additional parts of the version number.

[OrderedEquality]
public IReadOnlyList<VersionPart> AdditionalParts { get; }

Property Value

IReadOnlyList<VersionPart>

ContainsTemplateVariables

Indicates whether this version number contains a template variable (a substring enclosed in curly brackets, e.g {var}) .

[Browsable(false)]
[IgnoreEquality]
public bool ContainsTemplateVariables { get; }

Property Value

bool

Remarks

This must be false in regular feeds; true is only valid for templates.

FirstPart

The first part of the version number.

public VersionDottedList FirstPart { get; }

Property Value

VersionDottedList

Methods

CompareTo(ImplementationVersion?)

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.

public int CompareTo(ImplementationVersion? other)

Parameters

other ImplementationVersion

An object to compare with this instance.

Returns

int

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.
Greater than zero This instance follows other in the sort order.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string representation of the version. Safe for parsing!

public override string ToString()

Returns

string

TryCreate(string, out ImplementationVersion?)

Creates a new ImplementationVersion using the specified string representation.

public static bool TryCreate(string value, out ImplementationVersion? result)

Parameters

value string

The string to parse.

result ImplementationVersion

Returns the created ImplementationVersion if successfully; null otherwise.

Returns

bool

true if the ImplementationVersion was successfully created; false otherwise.

Operators

operator ==(ImplementationVersion?, ImplementationVersion?)

Indicates whether the object on the left is equal to the object on the right.

public static bool operator ==(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion

The left object

right ImplementationVersion

The right object

Returns

bool

true if the objects are equal; otherwise, false.

operator >(ImplementationVersion?, ImplementationVersion?)

public static bool operator >(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool

operator >=(ImplementationVersion?, ImplementationVersion?)

public static bool operator >=(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool

operator !=(ImplementationVersion?, ImplementationVersion?)

Indicates whether the object on the left is not equal to the object on the right.

public static bool operator !=(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion

The left object

right ImplementationVersion

The right object

Returns

bool

true if the objects are not equal; otherwise, false.

operator <(ImplementationVersion?, ImplementationVersion?)

public static bool operator <(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool

operator <=(ImplementationVersion?, ImplementationVersion?)

public static bool operator <=(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool