diff --git a/aspnetcore/fundamentals/configuration.md b/aspnetcore/fundamentals/configuration.md index cf28b752c1..791d82dcaa 100644 --- a/aspnetcore/fundamentals/configuration.md +++ b/aspnetcore/fundamentals/configuration.md @@ -201,7 +201,7 @@ You can recursively bind to each object in a class. Consider the following `AppO The following sample binds to the `AppOptions` class: -[!code-csharp[Main](configuration/sample/src/ObjectGraph/Program.cs?highlight=19-20)] +[!code-csharp[Main](configuration/sample/src/ObjectGraph/Program.cs?highlight=15-16)] **ASP.NET Core 1.1** and higher can use `Get`, which works with entire sections. `Get` can be more convienent than using `Bind`. The following code shows how to use `Get` with the sample above: diff --git a/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/ObjectGraph.csproj b/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/ObjectGraph.csproj index 4b28c5093a..d4b916731e 100644 --- a/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/ObjectGraph.csproj +++ b/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/ObjectGraph.csproj @@ -1,18 +1,14 @@  - netcoreapp1.0 - ObjectGraph + netcoreapp2.0 Exe - ObjectGraph - 1.0.4 - $(PackageTargetFallback);dnxcore50 - - - + + + diff --git a/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/Program.cs b/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/Program.cs index 1569ed29fd..29c20d22ee 100644 --- a/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/Program.cs +++ b/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/Program.cs @@ -1,18 +1,14 @@ -using Microsoft.Extensions.Configuration; -using System; +using System; using System.IO; +using Microsoft.Extensions.Configuration; -// Add these NuGet packages: -// "Microsoft.Extensions.Configuration.Binder" -// "Microsoft.Extensions.Configuration.FileExtensions" -// "Microsoft.Extensions.Configuration.Json": public class Program { public static void Main(string[] args = null) { var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json"); + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json"); var config = builder.Build(); @@ -20,5 +16,9 @@ public class Program config.GetSection("App").Bind(appConfig); Console.WriteLine($"Height {appConfig.Window.Height}"); + Console.WriteLine(); + + Console.WriteLine("Press a key..."); + Console.ReadKey(); } } diff --git a/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/appsettings.json b/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/appsettings.json index 95edbd76b5..4310c9c56f 100644 --- a/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/appsettings.json +++ b/aspnetcore/fundamentals/configuration/sample/src/ObjectGraph/appsettings.json @@ -11,4 +11,4 @@ "Width": "11" } } -} \ No newline at end of file +}