Class VersionRange
- Namespace
- ZeroInstall.Model
- Assembly
- ZeroInstall.Model.dll
Represents a (possibly disjoint) set of ranges of ImplementationVersions.
[TypeConverter(typeof(StringConstructorConverter<VersionRange>))]
[Serializable]
[Equatable]
public sealed class VersionRange : IEquatable<VersionRange>
- Inheritance
-
VersionRange
- Implements
- Inherited Members
Remarks
This class is immutable.
Ranges are separated by pipes (|). Each range is in the form "START..!END". The range matches versions where START <= VERSION < END. The start or end may be omitted. A single version number may be used instead of a range to match only that version, or !VERSION to match everything except that version.
Constructors
VersionRange()
Creates an empty version range (matches everything).
public VersionRange()
VersionRange(string)
Creates a new version range set from a string.
public VersionRange(string value)
Parameters
valuestringThe string containing the version ranges.
Exceptions
- FormatException
valueis not a valid version range string.
VersionRange(params VersionRangePart[])
Creates a new version range set.
public VersionRange(params VersionRangePart[] parts)
Parameters
partsVersionRangePart[]The individual ranges.
Fields
None
An "impossible" range matching no versions.
public static readonly VersionRange None
Field Value
Properties
Parts
The individual ranges.
[OrderedEquality]
public IReadOnlyList<VersionRangePart> Parts { get; }
Property Value
Methods
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe 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.
Intersect(VersionRange)
Intersects another version range set with this one and returns a new set as the result.
public VersionRange Intersect(VersionRange other)
Parameters
otherVersionRange
Returns
Match(ImplementationVersion)
Determines whether a specific version lies within this range set.
public bool Match(ImplementationVersion version)
Parameters
versionImplementationVersion
Returns
ToString()
Returns a string representation of the version range set. Safe for parsing!
public override string ToString()
Returns
TryCreate(string, out VersionRange?)
Creates a new VersionRange using the specified string representation.
public static bool TryCreate(string value, out VersionRange? result)
Parameters
valuestringThe string to parse.
resultVersionRangeReturns the created VersionRange if successfully;
nullotherwise.
Returns
- bool
trueif the VersionRange was successfully created;falseotherwise.
Operators
operator ==(VersionRange?, VersionRange?)
Indicates whether the object on the left is equal to the object on the right.
public static bool operator ==(VersionRange? left, VersionRange? right)
Parameters
leftVersionRangeThe left object
rightVersionRangeThe right object
Returns
- bool
true if the objects are equal; otherwise, false.
implicit operator VersionRange?(Constraint?)
Convenience cast for Constraints into VersionRanges.
public static implicit operator VersionRange?(Constraint? constraint)
Parameters
constraintConstraint
Returns
implicit operator VersionRange?(ImplementationVersion?)
Convenience cast for ImplementationVersions into VersionRanges that match that exact version.
public static implicit operator VersionRange?(ImplementationVersion? version)
Parameters
versionImplementationVersion
Returns
operator !=(VersionRange?, VersionRange?)
Indicates whether the object on the left is not equal to the object on the right.
public static bool operator !=(VersionRange? left, VersionRange? right)
Parameters
leftVersionRangeThe left object
rightVersionRangeThe right object
Returns
- bool
true if the objects are not equal; otherwise, false.