-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readmes for configuration packages, part 2 (#77982)
- Loading branch information
1 parent
c6549d9
commit cd3bd4c
Showing
8 changed files
with
158 additions
and
9 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/libraries/Microsoft.Extensions.Configuration.Ini/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Microsoft.Extensions.Configuration.Ini | ||
|
||
INI configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to read configuration parameters from [INI files](https://en.wikipedia.org/wiki/INI_file). You can use [IniConfigurationExtensions.AddIniFile](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iniconfigurationextensions.addinifile) extension method on `IConfigurationBuilder` to add INI configuration provider to the configuration builder. | ||
|
||
Documentation can be found at https://learn.microsoft.com/dotnet/core/extensions/configuration-providers#ini-configuration-provider | ||
|
||
## Contribution Bar | ||
- [x] [We consider new features, new APIs, bug fixes, and performance changes](https://github.com/dotnet/runtime/tree/main/src/libraries#contribution-bar) | ||
|
||
The APIs and functionality are mature, but do get extended occasionally. | ||
|
||
## Deployment | ||
[Microsoft.Extensions.Configuration.Ini](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Ini/) is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly. | ||
|
||
## Example | ||
The following example shows how to read the application configuration from INI file. | ||
|
||
```cs | ||
using System; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
// Build a configuration object from INI file | ||
IConfiguration config = new ConfigurationBuilder() | ||
.AddIniFile("appsettings.ini") | ||
.Build(); | ||
|
||
// Get a configuration section | ||
IConfigurationSection section = config.GetSection("Settings"); | ||
|
||
// Read configuration values | ||
Console.WriteLine($"Server: {section["Server"]}"); | ||
Console.WriteLine($"Database: {section["Database"]}"); | ||
} | ||
} | ||
``` | ||
|
||
To run this example, include an `appsettings.ini` file with the following content in your project: | ||
|
||
``` | ||
[Settings] | ||
Server=example.com | ||
Database=Northwind | ||
``` | ||
|
||
You can include a configuration file using a code like this in your `.csproj` file: | ||
|
||
```xml | ||
<ItemGroup> | ||
<Content Include="appsettings.ini"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 9 additions & 5 deletions
14
...tensions.Configuration.Json/src/README.md → ...t.Extensions.Configuration.Json/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/libraries/Microsoft.Extensions.Configuration.UserSecrets/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Microsoft.Extensions.Configuration.UserSecrets | ||
|
||
User secrets configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). User secrets mechanism enables you to override application configuration settings with values stored in the local secrets file. You can use [UserSecretsConfigurationExtensions.AddUserSecrets](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.usersecretsconfigurationextensions.addusersecrets) extension method on `IConfigurationBuilder` to add user secrets provider to the configuration builder. | ||
|
||
Documentation can be found at https://learn.microsoft.com/aspnet/core/security/app-secrets | ||
|
||
## Contribution Bar | ||
- [x] [We consider new features, new APIs, bug fixes, and performance changes](https://github.com/dotnet/runtime/tree/main/src/libraries#contribution-bar) | ||
|
||
The APIs and functionality are mature, but do get extended occasionally. | ||
|
||
## Deployment | ||
[Microsoft.Extensions.Configuration.UserSecrets](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.UserSecrets/) is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/libraries/Microsoft.Extensions.Configuration.Xml/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Microsoft.Extensions.Configuration.Xml | ||
|
||
XML configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to read configuration parameters from XML files. You can use [XmlConfigurationExtensions.AddXmlFile](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.xmlconfigurationextensions.addxmlfile) extension method on `IConfigurationBuilder` to add XML configuration provider to the configuration builder. | ||
|
||
Documentation can be found at https://learn.microsoft.com/dotnet/core/extensions/configuration-providers#xml-configuration-provider | ||
|
||
## Contribution Bar | ||
- [x] [We consider new features, new APIs, bug fixes, and performance changes](https://github.com/dotnet/runtime/tree/main/src/libraries#contribution-bar) | ||
|
||
The APIs and functionality are mature, but do get extended occasionally. | ||
|
||
## Deployment | ||
[Microsoft.Extensions.Configuration.Xml](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Xml/) is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly. | ||
|
||
## Example | ||
The following example shows how to read the application configuration from XML file. | ||
|
||
```cs | ||
using System; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
// Build a configuration object from XML file | ||
IConfiguration config = new ConfigurationBuilder() | ||
.AddXmlFile("appsettings.xml") | ||
.Build(); | ||
|
||
// Get a configuration section | ||
IConfigurationSection section = config.GetSection("Settings"); | ||
|
||
// Read simple values | ||
Console.WriteLine($"Server: {section["Server"]}"); | ||
Console.WriteLine($"Database: {section["Database"]}"); | ||
|
||
// Read nested values | ||
Console.WriteLine($"IPAddress: {section["Endpoint:IPAddress"]}"); | ||
Console.WriteLine($"Port: {section["Endpoint:Port"]}"); | ||
} | ||
} | ||
``` | ||
|
||
To run this example, include an `appsettings.xml` file with the following content in your project: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<Settings> | ||
<Server>example.com</Server> | ||
<Database>Northwind</Database> | ||
<Endpoint> | ||
<IPAddress>192.168.0.10</IPAddress> | ||
<Port>80</Port> | ||
</Endpoint> | ||
</Settings> | ||
</configuration> | ||
``` | ||
|
||
You can include a configuration file using a code like this in your `.csproj` file: | ||
|
||
```xml | ||
<ItemGroup> | ||
<Content Include="appsettings.xml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters