OKF4net.Catalog.Hosting 0.2.0

dotnet add package OKF4net.Catalog.Hosting --version 0.2.0
                    
NuGet\Install-Package OKF4net.Catalog.Hosting -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OKF4net.Catalog.Hosting" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OKF4net.Catalog.Hosting" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="OKF4net.Catalog.Hosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OKF4net.Catalog.Hosting --version 0.2.0
                    
#r "nuget: OKF4net.Catalog.Hosting, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OKF4net.Catalog.Hosting@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OKF4net.Catalog.Hosting&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=OKF4net.Catalog.Hosting&version=0.2.0
                    
Install as a Cake Tool

OKF4net.Catalog.Hosting

Microsoft.Extensions.DependencyInjection integration for the OKF4net.Catalog local knowledge catalog: one extension method, services.AddKnowledge(...), wires a catalog.json manifest into your host's IServiceCollection.

This package depends on Microsoft.Extensions.DependencyInjection.Abstractions only — the one explicit exception to OKF4net's zero-dependency policy, scoped narrowly to DI abstractions (see the project README for the full dependency policy).

Quick start

using OKF4net.Catalog;
using OKF4net.Catalog.Hosting;

services.AddKnowledge(o => o.AddCatalogFile("./config/catalog.json"));

This registers, all as singletons:

  • IKnowledgeCatalog — a FileKnowledgeCatalog over the given manifest.
  • IKnowledgeResolver — a DefaultKnowledgeResolver over that catalog.
  • KnowledgeCatalogOptions — the resolved catalog file path and catalog root (derived from the manifest file's own directory), for callers that want to inspect them directly.

Then resolve and use it anywhere in your host:

public sealed class SearchEndpoint(IKnowledgeResolver resolver)
{
    public async Task<KnowledgeContext> HandleAsync(string query, CancellationToken ct)
        => await resolver.SearchAsync(new KnowledgeQuery(query), ct);
}

Registration is lazy: no catalog file is read inside AddKnowledge itself. configure runs immediately and its result is validated at registration time (an ArgumentException/InvalidOperationException from a missing or duplicate AddCatalogFile call surfaces right away), but the catalog.json file itself is only parsed and path-validated the first time IKnowledgeCatalog (or IKnowledgeResolver) is actually resolved from the container — an invalid manifest surfaces as CatalogException from that first resolve, not from AddKnowledge.

V1 limits

  • Exactly one catalog per AddKnowledge call, and exactly one call wins. AddKnowledge supports a single AddCatalogFile call in its configure callback in V1 — a second AddCatalogFile call inside the same configure callback throws InvalidOperationException (AddBundle/ multi-catalog composition is cut as YAGNI; put every source in one catalog.json instead).
  • A second, separate AddKnowledge(...) call on the same IServiceCollection is silently ignored — the first one wins. The registrations use TryAddSingleton, so calling AddKnowledge more than once (e.g. once from your app and once from a library extension method) does not throw and does not error: whichever call ran first determines the catalog that ends up registered, and the second call's configure is still invoked and validated, but its registrations are dropped as no-ops. If you need more than one independently-configured catalog in the same process, register IKnowledgeCatalog/IKnowledgeResolver manually under distinct keys instead of relying on AddKnowledge twice.

See the OKF4net.Catalog README for the catalog model itself (manifest shape, hot-reload behavior, search semantics), and the project README for full documentation.

Licensed LGPL-3.0-or-later.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 0 7/27/2026