Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
alhugone committed Dec 15, 2018
1 parent d838042 commit 0fbf0a5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Built with the simplicity and promotion of best practices in mind
* Immutability
* Fail-fast
* Composition root
* Base what is need: ``services.BindToConfig<ConfigClass>(..)``
* Base what is need: ``services.AddBoundToConfig<ConfigClass>(..)``

*small, lightweight, free and open-source.*

## Example
Binding configuration Classes to app's configuration is very simple.
Startup.cs :
## Code example
In ConfigureServices method, just call AddFromConfig or AddBoundToConfig on services.
Startup.cs:

```csharp
public void ConfigureServices(IServiceCollection services)
Expand All @@ -35,8 +35,7 @@ public void ConfigureServices(IServiceCollection services)
BindOptions.DontThrowIfSectionIsMissingOrEmpty);
}
```
From now on SampleConfig1 and SmapleConfig2 is filled with proper values from configuration, and registered in DI, so that You can simpli declare it as constructor parameters of any class:
And then You can
From now on `SampleConfig1` and `SmapleConfig2` are filled with proper values from the configuration and registered in DI, so that You can simply declare it as constructor parameters of any class:

```csharp
public class ValuesController : ControllerBase
Expand Down
24 changes: 23 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ Built with the simplicity and promotion of best practices in mind
* Immutability
* Fail-fast
* Composition root
* Base what is need: ``services.BindToConfig<ConfigClass>(..)``
* Base what is need: ``services.AddBoundToConfig<ConfigClass>(..)``

*small, lightweight, free and open-source.*

============
Code example
============
| In `ConfigureServices` method, just call `AddFromConfig` or `AddBoundToConfig` on `services`.
| `Startup.cs`:
.. code-block:: csharp
public void ConfigureServices(IServiceCollection services)
Expand All @@ -39,3 +45,19 @@ Built with the simplicity and promotion of best practices in mind
BindOptions.DontThrowIfSectionIsMissingOrEmpty);
}
..
From now on `SampleConfig1` and `SmapleConfig2` are filled with proper values from the configuration and registered in DI, so that You can simply declare it as constructor parameters of any class:

.. code-block:: csharp
public class ValuesController : ControllerBase
{
...
public ValuesController(SampleConfig1 config1, SampleConfig2 config2, SampleConfig3 config3)
{
_config1 = config1;
_config2 = config2;
_config3 = config3;
}
}
..

0 comments on commit 0fbf0a5

Please sign in to comment.