Class LibraryIdentity
A library as a reference or a dependency asks for it: by its name, and by the identifier and version of its type library when it says which one it means.
public sealed record LibraryIdentity : IEquatable<LibraryIdentity>
- Inheritance
-
LibraryIdentity
- Implements
- Inherited Members
Remarks
The name is what source code qualifies the library's types with (DAO.Recordset), and it is unique among the libraries of a project. Libraries of
one name can still be several: DAO is the Access database engine's, DAO 3.6's and the DAO 2.5/3.51 compatibility library's, each a type library
of its own identifier or version. An identity with a Guid means one of them; one without means the library of that name
(RD-VBAL §2.3.1.2).
A version matches as LoadRegTypeLib matches a registered type library's: of the same identifier and major version, the description of exactly the
minor version asked for, or else the one of the highest minor version above it; one of another major version never matches (Choose(IEnumerable<LibraryDescription>)). An
identity that gives no major version takes the highest version of the identifier, and one that gives no minor version the highest minor version of its
major. One that gives a minor version and no major version is not valid (IsValid), and means no description.
Constructors
LibraryIdentity(string, Guid?, int?, int?)
A library as a reference or a dependency asks for it: by its name, and by the identifier and version of its type library when it says which one it means.
public LibraryIdentity(string Name, Guid? Guid = null, int? Major = null, int? Minor = null)
Parameters
NamestringThe name of the library.
GuidGuid?The identifier of the type library it means; null for the library of the name, whichever it is.
Majorint?The major version it means; null for any.
Minorint?The minor version of
Majorit means: a description of exactly this one, or else of the highest above it; null for the highest.
Remarks
The name is what source code qualifies the library's types with (DAO.Recordset), and it is unique among the libraries of a project. Libraries of
one name can still be several: DAO is the Access database engine's, DAO 3.6's and the DAO 2.5/3.51 compatibility library's, each a type library
of its own identifier or version. An identity with a Guid means one of them; one without means the library of that name
(RD-VBAL §2.3.1.2).
A version matches as LoadRegTypeLib matches a registered type library's: of the same identifier and major version, the description of exactly the
minor version asked for, or else the one of the highest minor version above it; one of another major version never matches (Choose(IEnumerable<LibraryDescription>)). An
identity that gives no major version takes the highest version of the identifier, and one that gives no minor version the highest minor version of its
major. One that gives a minor version and no major version is not valid (IsValid), and means no description.
Properties
Guid
The identifier of the type library it means; null for the library of the name, whichever it is.
public Guid? Guid { get; init; }
Property Value
- Guid?
IsValid
Whether the identity says which version it means: one that gives an identifier and a minor version gives a major version too. The version of an identity that gives no identifier is not read.
public bool IsValid { get; }
Property Value
Major
The major version it means; null for any.
public int? Major { get; init; }
Property Value
- int?
Minor
The minor version of Major it means: a description of exactly this one, or else of the highest above it; null for the
highest.
public int? Minor { get; init; }
Property Value
- int?
Name
The name of the library.
public string Name { get; init; }
Property Value
Version
The version as a description writes it (3.5); null when the identity gives no major version, and major.0 when it gives no
minor one.
public string? Version { get; }
Property Value
Methods
Accepts(LibraryDescription)
Whether a description is one this identity can mean: of the same name, and, when the identity gives one, of the same identifier and major version, and a minor version at least the one it asks for. An identity that is not valid (IsValid) accepts none.
public bool Accepts(LibraryDescription description)
Parameters
descriptionLibraryDescriptionThe description.
Returns
Choose(IEnumerable<LibraryDescription>)
Of the descriptions this identity accepts (Accepts(LibraryDescription)), the one it means: the one of exactly the version it asks for, and otherwise the one of the highest version.
public LibraryDescription? Choose(IEnumerable<LibraryDescription> candidates)
Parameters
candidatesIEnumerable<LibraryDescription>The descriptions of the name.
Returns
- LibraryDescription
The description, or null when it accepts none of them.
Of(LibraryDescription)
The identity of the type library a description was made from (Origin): its name, identifier and version.
public static LibraryIdentity Of(LibraryDescription description)
Parameters
descriptionLibraryDescriptionThe description.
Returns
- LibraryIdentity
The identity; one with no Guid when the description's origin states none.
ParseVersion(string?)
A version as a description writes it, major.minor, read: (3, 5) for "3.5", and (null, null) for a version that is not stated
or not of that form.
public static (int? Major, int? Minor) ParseVersion(string? version)
Parameters
versionstringThe version, as written.
Returns
ToString()
The identity as a problem or a message states it: the name, then the identifier and the version when it gives them, as it gives them (5 for a
major version and no minor one).
public override string ToString()
Returns
Operators
implicit operator LibraryIdentity(string)
The library of a name, whichever it is.
public static implicit operator LibraryIdentity(string name)
Parameters
namestringThe name of the library.