Skip to content

Commit

Permalink
bump version, docs and nuget for SqlSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
rofr committed Oct 6, 2020
1 parent 017762d commit 63b6328
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Fig.All/Fig.All.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/devrexlabs/fig</PackageProjectUrl>
<RepositoryUrl>https://github.com/devrexlabs/fig</RepositoryUrl>
<Copyright>Robert Friberg et al</Copyright>
<PackageReleaseNotes>Updated nugets, dump config as string</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Fig.AppSettingsJson\Fig.AppSettingsJson.csproj" />
<ProjectReference Include="..\Fig.AppSettingsXml\Fig.AppSettingsXml.csproj" />
<ProjectReference Include="..\Fig.Core\Fig.Core.csproj" />
<ProjectReference Include="..\Fig.SqlSettings\Fig.SqlSettings.csproj" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion Fig.SqlSettings/Fig.SqlSettings.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Venomaus</Authors>
<Title>Fig.SqlSettings</Title>
<Description>Fig support for sql providers</Description>
<Copyright>Venomaus</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/devrexlabs/fig</PackageProjectUrl>
<RepositoryUrl>https://github.com/devrexlabs/fig</RepositoryUrl>
<PackageReleaseNotes>Implementation of SqlProvider support for Fig</PackageReleaseNotes>
<PackageVersion>1.2.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ by subscribing to the `PropertyChanged` event.
* ini-files
* environment variables
* command line / string array
* Sql database
* Bring your own by implementing `ISettingsSource`

Sources provide key value pairs `(string,string)`.
Expand Down Expand Up @@ -217,7 +218,6 @@ MYAPP.COLOR
MYAPP.ENDPOINT
```


## Command line
Fig can take key/value paires passed on the command line. The default prefix is "--fig:" and default separator is "="
```c#
Expand All @@ -240,6 +240,38 @@ and `settingsBuilder.UseCommandLine(args, prefix: "")` yields:
retries
```

## Sql database
Version 1.9 introduces SqlSettings. Read keys and values from any sql database
that has an ADO.NET provider. (implements `IDbConnection`)

First, `Install-Package Fig.SqlSettings`, then use one of the `UseSql` extension method
overloads to setup a connection to your database.

```csharp
//pass an IDbConnection with a preconfigured connection string
IDbConnection connection = new SqlConnection("Data source=.;Integrated Security=true;Database=mydb");
var settings = new SettingsBuilder()
.UseSql(connection)
.Build();
```

```csharp
//pass a type parameter for the `IDbConnection` implementation class
//and a connection string key to pick up from AppSettingsXml / AppSettingsJson
var settings = new SettingsBuilder()
.UseAppSettingsJson("appsettings.json")
.UseSql<SqlConnection>("ConnectionStrings.SQLiteConnection")
.Build();
```
The SQL query used is `SELECT key, value FROM FigSettings`. You can pass your own query:

```
var settings = new SettingsBuilder()
.UseAppSettingsJson("appsettings.json")
.UseSql<SqlConnection>("ConnectionStrings.SQLiteConnection", "SELECT a,b FROM MySettings")
.Build();
```

# Combining sources
Use the `SettingsBuilder` to add sources in order of precedence.
Settings in above layers override settings with the same key in
Expand Down Expand Up @@ -277,7 +309,7 @@ You can also qualify an entire section of an ini or json file:
"Network:PROD" : {
"ip" : "10.0.0.1",
"port" : 3001
}
},

"Network:TEST" : {
"ip" : "127.0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.8.{build}
version: 1.9.{build}
image: Ubuntu1804
assembly_info:
patch: true
Expand Down

0 comments on commit 63b6328

Please sign in to comment.