Class VersionRange
Represents a (possibly disjoint) set of ranges of ImplementationVersions.
Implements
Namespace: ZeroInstall.Model
Assembly: ZeroInstall.Model.dll
Syntax
public sealed class VersionRange : Object
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).
Declaration
public VersionRange()
VersionRange(String)
Creates a new version range set from a a string.
Declaration
public VersionRange(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value | The string containing the version ranges. |
Exceptions
Type | Condition |
---|---|
FormatException |
|
VersionRange(VersionRangePart[])
Creates a new version range set.
Declaration
public VersionRange(params VersionRangePart[] parts)
Parameters
Type | Name | Description |
---|---|---|
VersionRangePart[] | parts | The individual ranges. |
Fields
None
An "impossible" range matching no versions.
Declaration
public static readonly VersionRange None
Field Value
Type | Description |
---|---|
VersionRange |
Properties
Parts
The individual ranges.
Declaration
public IReadOnlyList<VersionRangePart> Parts { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<VersionRangePart> |
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Equals(VersionRange)
Declaration
public bool Equals(VersionRange other)
Parameters
Type | Name | Description |
---|---|---|
VersionRange | other |
Returns
Type | Description |
---|---|
Boolean |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Intersect(VersionRange)
Intersects another version range set with this one and returns a new set as the result.
Declaration
public VersionRange Intersect(VersionRange other)
Parameters
Type | Name | Description |
---|---|---|
VersionRange | other |
Returns
Type | Description |
---|---|
VersionRange |
Match(ImplementationVersion)
Determines whether a specific version lies within this range set.
Declaration
public bool Match(ImplementationVersion version)
Parameters
Type | Name | Description |
---|---|---|
ImplementationVersion | version |
Returns
Type | Description |
---|---|
Boolean |
ToString()
Returns a string representation of the version range set. Safe for parsing!
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
TryCreate(String, out VersionRange)
Creates a new VersionRange using the specified string representation.
Declaration
public static bool TryCreate(string value, out VersionRange result)
Parameters
Type | Name | Description |
---|---|---|
String | value | The string to parse. |
VersionRange | result | Returns the created VersionRange if successfully; |
Returns
Type | Description |
---|---|
Boolean |
|
Operators
Equality(VersionRange, VersionRange)
Indicates whether the object on the left is equal to the object on the right.
Declaration
public static bool operator ==(VersionRange left, VersionRange right)
Parameters
Type | Name | Description |
---|---|---|
VersionRange | left | The left object |
VersionRange | right | The right object |
Returns
Type | Description |
---|---|
Boolean | true if the objects are equal; otherwise, false. |
Implicit(Constraint to VersionRange)
Convenience cast for Constraints into VersionRanges.
Declaration
public static implicit operator VersionRange(Constraint constraint)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint |
Returns
Type | Description |
---|---|
VersionRange |
Implicit(ImplementationVersion to VersionRange)
Convenience cast for ImplementationVersions into VersionRanges that match that exact version.
Declaration
public static implicit operator VersionRange(ImplementationVersion version)
Parameters
Type | Name | Description |
---|---|---|
ImplementationVersion | version |
Returns
Type | Description |
---|---|
VersionRange |
Inequality(VersionRange, VersionRange)
Indicates whether the object on the left is not equal to the object on the right.
Declaration
public static bool operator !=(VersionRange left, VersionRange right)
Parameters
Type | Name | Description |
---|---|---|
VersionRange | left | The left object |
VersionRange | right | The right object |
Returns
Type | Description |
---|---|
Boolean | true if the objects are not equal; otherwise, false. |