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>))]
public sealed class ImplementationVersion : IComparable<ImplementationVersion>, IEquatable<ImplementationVersion>
- Inheritance
-
objectImplementationVersion
- Implements
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 string.
public ImplementationVersion(string value)
Parameters
valuestringThe string containing the version information.
Exceptions
- FormatException
valueis not a valid version string.
ImplementationVersion(Version)
Creates a new implementation version from a .NET Version.
public ImplementationVersion(Version version)
Parameters
ImplementationVersion(VersionDottedList, params VersionPart[])
Creates a new implementation version.
public ImplementationVersion(VersionDottedList firstPart, params VersionPart[] additionalParts)
Parameters
firstPartVersionDottedListThe first part of the version number.
additionalPartsVersionPart[]All additional parts of the version number.
Properties
AdditionalParts
All additional parts of the version number.
public IReadOnlyList<VersionPart> AdditionalParts { get; }
Property Value
ContainsTemplateVariables
Indicates whether this version number contains a template variable (a substring enclosed in curly brackets, e.g {var}) .
[Browsable(false)]
public bool ContainsTemplateVariables { get; }
Property Value
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
Methods
CompareTo(ImplementationVersion?)
public int CompareTo(ImplementationVersion? other)
Parameters
otherImplementationVersion
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
FromSemVer(string)
Creates a new ImplementationVersion from a SemVer string.
public static ImplementationVersion FromSemVer(string value)
Parameters
valuestring
Returns
Remarks
Tries to parse as much as possible, while ignoring parts that can't be mapped to 0install version numbers. Returns 0 for entirely unparsable values.
GetHashCode()
public override int GetHashCode()
Returns
ToString()
Returns a string representation of the version. Safe for parsing!
public override string ToString()
Returns
TryCreate(string, out ImplementationVersion?)
Creates a new ImplementationVersion using the specified string representation.
public static bool TryCreate(string value, out ImplementationVersion? result)
Parameters
valuestringThe string to parse.
resultImplementationVersionReturns the created ImplementationVersion if successfully;
nullotherwise.
Returns
- bool
trueif the ImplementationVersion was successfully created;falseotherwise.
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
leftImplementationVersionThe left object
rightImplementationVersionThe right object
Returns
- bool
true if the objects are equal; otherwise, false.
operator >(ImplementationVersion?, ImplementationVersion?)
public static bool operator >(ImplementationVersion? left, ImplementationVersion? right)
Parameters
leftImplementationVersionrightImplementationVersion
Returns
operator >=(ImplementationVersion?, ImplementationVersion?)
public static bool operator >=(ImplementationVersion? left, ImplementationVersion? right)
Parameters
leftImplementationVersionrightImplementationVersion
Returns
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
leftImplementationVersionThe left object
rightImplementationVersionThe 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
leftImplementationVersionrightImplementationVersion
Returns
operator <=(ImplementationVersion?, ImplementationVersion?)
public static bool operator <=(ImplementationVersion? left, ImplementationVersion? right)
Parameters
leftImplementationVersionrightImplementationVersion