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
stringThe 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
ImplementationVersion(VersionDottedList, params VersionPart[])
Creates a new implementation version.
public ImplementationVersion(VersionDottedList firstPart, params VersionPart[] additionalParts)
Parameters
firstPart
VersionDottedListThe 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
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
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?)
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
ImplementationVersionAn 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
objectThe object to compare with the current object.
Returns
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
TryCreate(string, out ImplementationVersion?)
Creates a new ImplementationVersion using the specified string representation.
public static bool TryCreate(string value, out ImplementationVersion? result)
Parameters
value
stringThe string to parse.
result
ImplementationVersionReturns 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
ImplementationVersionThe left object
right
ImplementationVersionThe 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
ImplementationVersionright
ImplementationVersion
Returns
operator >=(ImplementationVersion?, ImplementationVersion?)
public static bool operator >=(ImplementationVersion? left, ImplementationVersion? right)
Parameters
left
ImplementationVersionright
ImplementationVersion
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
left
ImplementationVersionThe left object
right
ImplementationVersionThe 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
ImplementationVersionright
ImplementationVersion
Returns
operator <=(ImplementationVersion?, ImplementationVersion?)
public static bool operator <=(ImplementationVersion? left, ImplementationVersion? right)
Parameters
left
ImplementationVersionright
ImplementationVersion