Skip to content

Commit a612c51

Browse files
authored
Merge pull request #30 from codebytes/updated-samples
Add solution file for .NET configuration projects
2 parents 9dff1f2 + 9c352fc commit a612c51

File tree

633 files changed

+3743
-75243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

633 files changed

+3743
-75243
lines changed

09-hosted-console-template/HostedConsoleTemplate.csproj renamed to 01-generic-host/GenericHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
11+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
1212
</ItemGroup>
1313

1414
</Project>
File renamed without changes.

01-generic-host/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 01 - Generic Host
2+
3+
Introduces generic host template using `Host.CreateApplicationBuilder`.
4+
5+
## Run
6+
7+
```powershell
8+
dotnet run --project 01-generic-host
9+
```
10+
11+
## Key Points
12+
13+
- Foundation for adding services, logging, configuration in a structured way.
14+
- Execution continues after initial code until host shutdown.
File renamed without changes.
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// See https://aka.ms/new-console-template for more information
2-
Console.WriteLine("Hello, World!");
1+
// See https://aka.ms/new-console-template for more information
2+
Console.WriteLine("Hello, World!");

02-basic-console/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 02 - Basic Console
2+
3+
Minimal .NET console template baseline. Used as a control sample before adding configuration providers.
4+
5+
## Run
6+
7+
```powershell
8+
dotnet run --project 02-basic-console
9+
```
10+
11+
## Key Points
12+
13+
- Single `Program.cs` using top-level statements.
14+
- Prints "Hello, World!".
15+
- No configuration providers yet (contrast with later samples).
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.2" />
13-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
12+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.8" />
13+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.8" />
1414
</ItemGroup>
1515

1616
<ItemGroup>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using Microsoft.Extensions.Configuration;
2-
3-
IConfigurationRoot configuration = new ConfigurationBuilder()
4-
.AddJsonFile("config.json")
5-
.Build();
6-
7-
var name = "World";
8-
// See https://aka.ms/new-console-template for more information
9-
Console.WriteLine($"{configuration["greeting"]}, {name}!");
10-
Console.WriteLine($"Configuration: {configuration["environment"]}");
1+
using Microsoft.Extensions.Configuration;
2+
3+
IConfigurationRoot configuration = new ConfigurationBuilder()
4+
.AddJsonFile("config.json")
5+
.Build();
6+
7+
var name = "World";
8+
// See https://aka.ms/new-console-template for more information
9+
Console.WriteLine($"{configuration["greeting"]}, {name}!");
10+
Console.WriteLine($"Configuration: {configuration["environment"]}");

03-json-config/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 03 - JSON Configuration
2+
3+
Introduces the JSON configuration provider via `AddJsonFile("config.json")`.
4+
5+
## Run
6+
7+
```powershell
8+
dotnet run --project 03-json-config
9+
```
10+
11+
## Key Points
12+
13+
- Builds an `IConfigurationRoot` with a single JSON file.
14+
- Accesses values using indexer: `configuration["greeting"]`.
15+
- Establishes baseline for precedence demos (env vars, command line) in later samples.
16+
17+
## Try
18+
19+
Edit `config.json` and re-run to see value changes (no reload-on-change here).

0 commit comments

Comments
 (0)