This directory contains runnable examples for Cocoar.Configuration. Each subfolder is an independent project you can open, run, and modify.
- SimplifiedCoreExample – Pure core library usage without DI (
ConfigManageronly) - BasicUsage – Common ASP.NET Core pattern with file + environment overrides
- FileLayering – Multiple JSON file layering (base + env + local)
- StaticProviderExample – Static seeding with JSON strings and factory functions
- CommandLineExample – Command-line argument provider with configurable prefixes
- HttpPollingExample – Remote/polling configuration pattern
- MicrosoftAdapterExample – Bridging existing
IConfiguration/IConfigurationSourceproviders - GenericProviderAPI – Using the generic provider registration API
- ConditionalRulesExample –
When()with config-aware predicates for conditional rule execution - DynamicDependencies – Later rules derive values from earlier configurations
- AggregateRules – Composable rule grouping (
FromFilessugar) with byte-level JSON merge - TupleReactiveExample – Tuple-based reactive multi-config snapshot & aligned emission demo
- MultiTenancyExample – The same type resolves to a different value per tenant: one flat rule list with a global base + a
.TenantScoped()overlay whose file path is interpolated fromaccessor.Tenant; sparse per-tenant inheritance
- ExposeExample – Interface exposure without DI frameworks
- AspNetCoreExample – Minimal API exposing configuration via endpoints
- ServiceBackedConfig – DI-aware service-backed configuration (ADR-006): eager Layer-1 + lazy
IServiceProvider-gated Layer-2 that activates on host start via a recompute - TestingOverridesExample – Test isolation with
CocoarTestConfiguration(Replace/Appendoverrides)
- WritableStoreExample – Writable sparse-overlay store (
FromStore): set/reset/clear plusDescribeAsyncprovenance - SecretsBasicExample – Basic
Secret<T>usage with a self-signed certificate - SecretsCertificateExample – Production-ready secrets with certificate-from-file decryption of pre-encrypted values
cd src/Examples/BasicUsage
dotnet runSome examples expect local JSON like config.json, base.json, etc. Copy the inline examples from the source Program.cs comments.
Currently examples use ProjectReference to always reflect the latest API. To test against a published package:
- Remove the
<ProjectReference/>entries - Add:
<ItemGroup>
<PackageReference Include="Cocoar.Configuration" Version="1.0.0" />
</ItemGroup>(And any adapter/provider packages you need.)
Examples are excluded from packing. The build is directory-based — there is no solution file. Build them along with the rest of the source tree:
dotnet build ./src -c Release- Create
src/Examples/<Name>/<Name>.csproj(copy one of the existing ones) - Add
Program.cswith top-level statements (or aMain) - Add it to the list above
The directory-based build picks up the new project automatically — no solution file to update.
Feel free to keep examples minimal—prefer a single Program.cs unless the scenario requires more.