From d0d9760503d211026f17a7579fe573b231f899ef Mon Sep 17 00:00:00 2001
From: "MSDN.WhiteKnight" <35516665+MSDN-WhiteKnight@users.noreply.github.com>
Date: Wed, 21 Sep 2022 05:26:09 +0500
Subject: [PATCH] Add markdown readme for
Microsoft.Extensions.Configuration.Json (#75876)
---
...osoft.Extensions.Configuration.Json.csproj | 4 +-
.../src/README.md | 66 +++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletion(-)
create mode 100644 src/libraries/Microsoft.Extensions.Configuration.Json/src/README.md
diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/src/Microsoft.Extensions.Configuration.Json.csproj b/src/libraries/Microsoft.Extensions.Configuration.Json/src/Microsoft.Extensions.Configuration.Json.csproj
index 47373297f2a..121cb04bd5d 100644
--- a/src/libraries/Microsoft.Extensions.Configuration.Json/src/Microsoft.Extensions.Configuration.Json.csproj
+++ b/src/libraries/Microsoft.Extensions.Configuration.Json/src/Microsoft.Extensions.Configuration.Json.csproj
@@ -6,7 +6,8 @@
true
true
true
- JSON configuration provider implementation for Microsoft.Extensions.Configuration.
+ JSON configuration provider implementation for Microsoft.Extensions.Configuration. This package enables you to read your application's settings from a JSON file. You can use JsonConfigurationExtensions.AddJsonFile extension method on IConfigurationBuilder to add the JSON configuration provider to the configuration builder.
+ README.md
@@ -17,6 +18,7 @@
+
diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/src/README.md b/src/libraries/Microsoft.Extensions.Configuration.Json/src/README.md
new file mode 100644
index 00000000000..869626b27e8
--- /dev/null
+++ b/src/libraries/Microsoft.Extensions.Configuration.Json/src/README.md
@@ -0,0 +1,66 @@
+## About
+
+JSON configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to read your application's settings from a JSON file. You can use [JsonConfigurationExtensions.AddJsonFile](https://docs.microsoft.com/dotnet/api/microsoft.extensions.configuration.jsonconfigurationextensions.addjsonfile) extension method on `IConfigurationBuilder` to add the JSON configuration provider to the configuration builder.
+
+For more information, see the documentation:
+
+- [Configuration in .NET](https://docs.microsoft.com/dotnet/core/extensions/configuration)
+- [Microsoft.Extensions.Configuration.Json namespace](https://docs.microsoft.com/dotnet/api/microsoft.extensions.configuration.json)
+
+## Example
+
+The following example shows how to read application settings from the JSON configuration file.
+
+```cs
+using System;
+using Microsoft.Extensions.Configuration;
+
+class Program
+{
+ static void Main()
+ {
+ // Build a configuration object from JSON file
+ IConfiguration config = new ConfigurationBuilder()
+ .AddJsonFile("appsettings.json")
+ .Build();
+
+ // Get a configuration section
+ IConfigurationSection section = config.GetSection("Settings");
+
+ // Read simple values
+ Console.WriteLine($"Server: {section["Server"]}");
+ Console.WriteLine($"Database: {section["Database"]}");
+
+ // Read a collection
+ Console.WriteLine("Ports: ");
+ IConfigurationSection ports = section.GetSection("Ports");
+
+ foreach (IConfigurationSection child in ports.GetChildren())
+ {
+ Console.WriteLine(child.Value);
+ }
+ }
+}
+```
+
+To run this example, include an `appsettings.json` file with the following content in your project:
+
+```json
+{
+ "Settings": {
+ "Server": "example.com",
+ "Database": "Northwind",
+ "Ports": [ 80, 81 ]
+ }
+}
+```
+
+You can include a configuration file using a code like this in your `.csproj` file:
+
+```xml
+
+
+ Always
+
+
+```
--
GitLab