-
Notifications
You must be signed in to change notification settings - Fork 5
Config File Setup
Johelvis Guzman edited this page Mar 26, 2019
·
18 revisions
If you wish to use the configuration files to configure the repositories, please follow these steps:
Element | Description | Attributes |
---|---|---|
defaultContextFactory | Defines the default repository context factory to use | Type string |
interceptors | Accepts a collection of interceptor elements | |
parameters | Acceps a collection of parameter elements |
App.config In order for the repositories to read data from the App.config the user will need to add a custom section handler and a configuration section:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- Configuration section-handler declaration area. -->
<configSections>
<section name="repository" type="DotNetToolkit.Repository.Internal.ConfigFile.ConfigurationSection, DotNetToolkit.Repository" />
<!-- Other <section> and <sectionGroup> elements. -->
</configSections>
<!-- Configuration section settings area. -->
<repository>
<defaultContextFactory type="DotNetToolkit.Repository.InMemory.Internal.InMemoryRepositoryContextFactory, DotNetToolkit.Repository.InMemory" />
<interceptors>
<interceptor type="ExampleApplication.TestRepositoryInterceptor, ExampleApplication">
<parameters>
<parameter value="random parameter"/>
</parameters>
</interceptor>
</interceptors>
</repository>
</configuration>
appsettings.config In order for the repositories to read data from the appsettings.json file the user will need to add a section to the file:
{
"repository": {
"defaultContextFactory": {
"type": "DotNetToolkit.Repository.InMemory.Internal.InMemoryRepositoryContextFactory, DotNetToolkit.Repository.InMemory"
},
"interceptors": [
{
"type": "ExampleApplication.TestRepositoryInterceptor, ExampleApplication",
"parameters": [
{
"type": "System.String",
"value": "random param"
},
{
"type": "System.Boolean",
"value": "True"
}
]
}
]
}
}
Additionally, any interceptor type that is defined in the configuration file can be resolved by using the RepositoryInterceptorProvider.SetDefaultFactory.