Host Services
Static services in PluginSdk.Services that expose host-app functionality back to plugins — each is a thin static class wrapping a delegate the host wires up at startup, so plugins call them the same way regardless of what's running underneath.
| Service | Purpose |
|---|---|
FuzzyMatchService | IsMatch(pattern, text) — whether text (or one of its aliases) matches an fzf-syntax pattern, using the exact same matching the host's own search uses; GetHighlightMask(text, query) — the per-character highlight mask for that pair, using the same literal/fuzzy/alias fallback tiers (including CJK pinyin) the host's own results highlight with, so a plugin's results highlight consistently instead of only handling a literal substring match. |
TranslationService | Get(key) / Format(key, args) for runtime lookups against the active language; LoadEmbeddedTranslations(assembly, cultureKey, typeName) to load a plugin's own embedded JSON translations; GetSupportedCultures(assembly); GetCurrentCulture() — the app's currently selected UI language (e.g. "zh-CN"), a user setting independent of the OS system locale. Reach for this only when you need the raw culture code itself (e.g. to put in an HTTP Accept-Language header or pick a translation API's target language) — CultureInfo.CurrentUICulture reflects the OS locale, not this setting, and will silently disagree with it whenever a user's Windows language and in-app language differ. |
IconService | GetIcon(path, isDir) and GetThumbnail(path, size) — cached shell icon/thumbnail extraction, so a plugin never has to shell out to the Windows icon APIs itself. |
FavoritesService | GetFavorites() — read-only access to the user's Favorites list (FavoriteItem: Name, Path). |
HistoryService | GetHistoryEntries() — every recorded History entry, most-recently-opened first, as HistoryEntry { Keyword, Path, Kind, Time } (Kind is a HistoryEntryKind: File / Folder / Application; Keyword is the search text that led to it, empty if opened directly from a Startup Panel tab with no query typed; Time is Unix seconds). Each path appears at most once, under whichever keyword most recently led to it. |
FileMetadataService | GetMetadataAsync(paths) — batched Size/Created/Modified/Accessed lookup (FileMetadata) for a path that isn't already one of your current results — every ISearchResult already carries this via its own Metadata property at no cost (see Abstractions), so reach for this service only for paths you got some other way (e.g. from your own config). |
DirectoryIndexerService | RegisterDirectory(pluginId, path, recursive, filterPattern) / UnregisterDirectories(pluginId) / SearchDirectoriesAsync(pluginId, query, token) / NotifyDirectoryChanged(pluginId) — lets a plugin register its own directories for background indexing and USN monitoring without reimplementing that machinery. |
PluginSettingsService | GetSetting<T>(pluginId, key, defaultValue) — read-only access to a plugin's own persisted settings from the host's config store. Falls back through three tiers: the persisted value if the user has ever saved one, then your IConfigurable schema's own DefaultValue for that field if nothing was persisted, then the defaultValue argument you passed as a last resort — so a schema-declared default is the single source of truth and doesn't need a second hardcoded copy in your call site. If you cache a setting instead of re-reading it every call, subscribe to the SettingChanged(pluginId, key) event and drop your cache when it fires for your plugin — the host raises it right after a settings-page save, which is the only reliable point to invalidate against (a per-keystroke or polling check will not see a change until whatever coincidentally triggers it next, or never). |
SearchRefreshService | RefreshIfMatches(queryMatches) — for an IInstantResultProvider whose data arrives asynchronously (see IInstantResultProvider): once your background fetch completes and you've cached the result, call this with a predicate over a search's current query text, and the host re-runs every active search that predicate matches so the now-cached result actually appears without the user needing to retype anything. |
Logger | Log(message, level = LogLevel.Info) — writes to the App's log file, visible in Settings → Service Status → App exactly like the host's own log lines. |
PluginPromptService | Prompt(title, fields, initialValues?) — shows a small modal asking for the given PluginConfigField values (the same field schema/rendering IConfigurable's Configure dialog uses), pre-filled from initialValues (matched by Key) or each field's own DefaultValue. Returns the entered values keyed by field Key, or null if the user cancelled — these values are never read from or written to the plugin's actual persisted settings, so it's safe to reuse a config field's schema purely for one-off input (e.g. "name this before adding it") without touching the real setting behind it. |
LogLevel is Error / Warn / Info / Debug, matching the level filter in the Service Status log viewer.