Table of Contents

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 a string.

public VersionRange(string value)

Parameters

value string

The string containing the version ranges.

Exceptions

FormatException

value is not a valid version range string.

VersionRange(params VersionRangePart[])

Creates a new version range set.

public VersionRange(params VersionRangePart[] parts)

Parameters

parts VersionRangePart[]

The individual ranges.

Fields

None

An "impossible" range matching no versions.

public static readonly VersionRange None

Field Value

VersionRange

Properties

Parts

The individual ranges.

[OrderedEquality]
public IReadOnlyList<VersionRangePart> Parts { get; }

Property Value

IReadOnlyList<VersionRangePart>

Methods

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.

Intersect(VersionRange)

Intersects another version range set with this one and returns a new set as the result.

public VersionRange Intersect(VersionRange other)

Parameters

other VersionRange

Returns

VersionRange

Match(ImplementationVersion)

Determines whether a specific version lies within this range set.

public bool Match(ImplementationVersion version)

Parameters

version ImplementationVersion

Returns

bool

ToString()

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

public override string ToString()

Returns

string

TryCreate(string, out VersionRange?)

Creates a new VersionRange using the specified string representation.

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

Parameters

value string

The string to parse.

result VersionRange

Returns the created VersionRange if successfully; null otherwise.

Returns

bool

true if the VersionRange was successfully created; false otherwise.

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

left VersionRange

The left object

right VersionRange

The 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

constraint Constraint

Returns

VersionRange

implicit operator VersionRange?(ImplementationVersion?)

Convenience cast for ImplementationVersions into VersionRanges that match that exact version.

public static implicit operator VersionRange?(ImplementationVersion? version)

Parameters

version ImplementationVersion

Returns

VersionRange

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

left VersionRange

The left object

right VersionRange

The right object

Returns

bool

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