MyDotey.SCF.Simple
1.4.0
See the version list below for details.
dotnet add package MyDotey.SCF.Simple --version 1.4.0
NuGet\Install-Package MyDotey.SCF.Simple -Version 1.4.0
<PackageReference Include="MyDotey.SCF.Simple" Version="1.4.0" />
paket add MyDotey.SCF.Simple --version 1.4.0
#r "nuget: MyDotey.SCF.Simple, 1.4.0"
// Install MyDotey.SCF.Simple as a Cake Addin #addin nuget:?package=MyDotey.SCF.Simple&version=1.4.0 // Install MyDotey.SCF.Simple as a Cake Tool #tool nuget:?package=MyDotey.SCF.Simple&version=1.4.0
SCF: Simple Configuration Facade
SCF, short for Simple Configuration Facade, is an abtraction between Code and Outer Configuration (properties file, env variable, system property, yaml file, ... , etc.). It's namely like slf4j (Simple Logging Facade for Java), and has the same position in the configuration world.
Usage
Examples
https://github.com/mydotey/scf-best-practice
Features
Strong Type
Core abstraction is Property<K, V>, with strong-typed K & strong-typed value.
Safe
A value filter can be used to prevent bad property value configured.
Dynamic
Each property can be dynamic & listenable if it changes dynamicly.
Multiple Sources
Multiple sources can work together with different priorities. Property value is caculated by their priority automatically.
Extensible
scf-core only has a few interface abstractions and default implementation. Feel free to extend the default or write your own new implementation.
Some extentions:
Lightweight
No thread is used. Only use a little memory to cache the properties.
Easy to Use
scf-simple gives implementation on the most common used simplest Property<String, String>
: properties file, memory Map, system properties, env variables, etc.
See also:
Core Concepts
Property
A configuration item is used standalone in Code, with a unique Property Config and a strong-typed Value.
Code can listen the change of a dynamic changed property. Value of dynamic property is updated by the Configuration Manager automatically.
Property Config
Config for a Property with the following parts:
Key: uniquely identifies a Property in a Configuration Manager, can be a String, or any other strong-typed object
Value Type: value type of a properpty
Default Value: used when Property not configured in any Configuration Source
Value Converter: convert a value to another type, a source has <K, V1>, but the Code needs <K, V2>, a converter <V1, V2> can be used to automatically convert value of type V1 to value of type V2
Value Filter: give a chance to check the value got from the Configuration Source, mostly used to validate the value
Configuration Source
A property can be configured in various ways. For example, a HashMap in memory, or a properties file, or env variable, or Java system property, or yaml file, ... etc.
Multiple ways can be used together! Each way is a configuration source. Each source is responsible for providing a value for a property.
Sometimes a source cannot provide a value, provide null instead.
The key is not recognized by the source. For example, key type is another strong-typed object { key: request.timeout, labels: { dc: aws-us-east1, app: 100000 } }, but the source only accepts String key.
The property is not configured in the source.
The property value in the source is of type A, but the code needs type B, and no converter <A, B> provided in the property config
Configuration Manager
A configuration manager is a configuration facade for the Code. Code gets a property from the manager, and doesn't care how/where the property is configured.
Manager provides 2 kinds of API:
<K, V> Property<K, V> getProperty(PropertyConfig<K, V> config)
: used for stable properties with a stable key, returns a unique property object. Manager keeps the stable properties and updates them automatically when property value changes. Code can keep it somewhere and use it multiple times.<V> V getPropertyValue(PropertyConfig<K, V> config)
: used for non-stable properties with a non-stable key. For example, a visitor IP is used as part of a key, don't know how many keys app has, don't know when the property is configured and used.
Sources & Source Priority
A manager can manage multiple configuration sources. Different source has different priority. The manager gets property value from the sources in the order of the source priority.
Relationship of Core Concepts
Core Logic
Developers
- Qiang Zhao koqizhao@outlook.com
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- MyDotey.SCF (>= 1.4.0)
- NLog (>= 4.5.0)
- System.Collections.Immutable (>= 1.5.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on MyDotey.SCF.Simple:
Package | Downloads |
---|---|
MyDotey.SCF.Apollo
SCF Apollo Configuration Source |
|
MyDotey.SCF.Labeled
for scf labeled usage |
|
MyDotey.SCF.Bom
SCF, short for Simple Configuration Facade, an abstraction between code and outer configuration |
GitHub repositories
This package is not used by any popular GitHub repositories.
SCF, short for Simple Configuration Facade, an abstraction between code and outer configuration