Class StoreCatalogService
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
The store catalogue: what each popular project is about and what it does, decided outside the app.
public sealed class StoreCatalogService
- Inheritance
-
StoreCatalogService
- Inherited Members
Remarks
The rule-based tags (StoreTagService) read a title and a one-line description, and
that is not enough: a mod about backpacks and a mod about armour are both "equipment" to anyone
counting words. So a pipeline in tools/store-catalog asks a small decision model one closed
question per project, and a text model for a sentence in five languages, and publishes the answers
as one gzip on the catalog branch. This class is the app's end of it.
It is a read-only, anonymous download of a public file, the same kind of request as the update check: nothing about the user or the server goes out, there is no key in the app, and the models are never called from here. The file is fetched at most once a day, with its ETag, and kept on disk, so the store works offline on the last one. Everything in it is treated as data from the outside: size-capped, shape-checked, and ignored whole if anything about it is wrong, because a store with the rule-based tags is a working store and one with half a catalogue is not.
What the catalogue says never beats a person: a hand-written summary in
store-summaries.json comes first, and tags it names that the app does not know are skipped.
Constructors
StoreCatalogService(string?, HttpClient?, string?, Func<DateTimeOffset>?)
public StoreCatalogService(string? cacheFolder = null, HttpClient? http = null, string? url = null, Func<DateTimeOffset>? clock = null)
Parameters
cacheFolderstringhttpHttpClienturlstringclockFunc<DateTimeOffset>
Fields
DefaultUrl
Where the pipeline publishes. A raw file, so the request carries nothing to log.
public const string DefaultUrl = "https://raw.githubusercontent.com/JuanP-G/MC-ServerLauncher/catalog/store-catalog.json.gz"
Field Value
Properties
Count
How many projects the catalogue covers. Zero until one has been downloaded.
public int Count { get; }
Property Value
Shared
Shared instance. Declared after the static fields it uses: static initialisers run in the order they are written, and the constructor needs them.
public static StoreCatalogService Shared { get; }
Property Value
Methods
Find(string?)
The entry for a Modrinth project id, or null when the catalogue has none.
public StoreCatalogEntry? Find(string? projectId)
Parameters
projectIdstring
Returns
RefreshAsync(CancellationToken)
Fetches the catalogue if the copy on disk is more than a day old, and installs it when it parses. Never throws: offline, or GitHub down, or a file that does not parse, all leave the last good copy in place.
public Task<bool> RefreshAsync(CancellationToken ct = default)
Parameters
Returns
SummaryFor(string?, string)
The sentence for a project in language (a two-letter code), English when
that language is missing, null when the catalogue has nothing for it.
public string? SummaryFor(string? projectId, string language)