Welcome to our documentation!
Configuration
Frameworks
.NET
Operating Systems
Android
iOS
Windows
Configuration can be used without any other Shiny module. It does not require the base Shiny hooks in order to function.
Features
Section titled “Features”- All the power of IConfiguration
- Load JSON from packaged sources (whitelabellers can unpack, edit, & repack the config)
- Preferences based configuration source with writebacks
- HTTP remote configuration with local caching
- Environment variable based file name lookups (ie. appsettings.apple.debug.json)
The Problem
Section titled “The Problem”Microsoft really did create a great set of abstractions for configuration. You can store a set of key/values, cause a reload when a configuration source changes, & bind to strongly typed objects using Microsoft.Extensions.Configuration.Binder. On Mobile though, NONE of the current providers work really well.
Why?
- A big feature for IConfiguration, is the ability to trigger a reload of its source without restarting the application. Changing an appsettings.json file during runtime causes the IConfiguration to trigger a reload notification.
- Mobile doesn’t really have an appsettings.json. Sure you could put this in an embedded resource, but then it is readonly at all times other than the build process… after that - it is locked in place.
- Essentially, IConfiguration becomes a string based dictionary for all intents and purposes - pretty useless considering.
The Solution
Section titled “The Solution”How Shiny.Extensions.Configuration brings the power of IConfiguration to Mobile!
- A platform preferences configuration source which allows you to WRITE a value back using
IConfiguration[key] = value - A whitelabellers dream - the ability to unpack, change a json config file, and repack without triggering a build by using proper platform directories to load up the JSON files while still having the power of a proper configuration library internally.
- Fetch configuration from a remote HTTP server with local caching and reactive updates.
var config = new ConfigurationBuilder() .AddJsonPlatformBundle() .AddPlatformPreferences() .Build();Or with MAUI:
builder.Configuration .AddJsonPlatformBundle() .AddPlatformPreferences();Providers
Section titled “Providers”| Provider | Description |
|---|---|
| JSON Platform Bundle | Load JSON config files from platform-specific bundled locations |
| Platform Preferences | Read/write configuration backed by platform preferences |
| Remote Configuration | Fetch configuration from a remote HTTP server |