|
@@ -1,13 +1,9 @@
|
|
|
using CustomHostingDemo.Logging;
|
|
using CustomHostingDemo.Logging;
|
|
|
-using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Ninject;
|
|
using Ninject;
|
|
|
-using System;
|
|
|
|
|
using System.CommandLine;
|
|
using System.CommandLine;
|
|
|
using System.CommandLine.Builder;
|
|
using System.CommandLine.Builder;
|
|
|
using System.CommandLine.Parsing;
|
|
using System.CommandLine.Parsing;
|
|
|
-using System.IO;
|
|
|
|
|
-using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace CustomHostingDemo
|
|
namespace CustomHostingDemo
|
|
|
{
|
|
{
|
|
@@ -16,21 +12,13 @@ namespace CustomHostingDemo
|
|
|
static int Main(string[] args)
|
|
static int Main(string[] args)
|
|
|
{
|
|
{
|
|
|
var kernel = new StandardKernel(
|
|
var kernel = new StandardKernel(
|
|
|
|
|
+ new ConfigurationModule(),
|
|
|
new LoggingModule(),
|
|
new LoggingModule(),
|
|
|
new CommandHandlerModule()
|
|
new CommandHandlerModule()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- var config = new ConfigurationBuilder()
|
|
|
|
|
- .SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
|
|
|
|
|
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
|
|
|
|
- .AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "custom-demo.json"), optional: true, reloadOnChange: false)
|
|
|
|
|
- .Build();
|
|
|
|
|
-
|
|
|
|
|
- kernel.Bind<IConfiguration>().ToConstant(config).InSingletonScope();
|
|
|
|
|
-
|
|
|
|
|
var logger = kernel.Get<Logger<Program>>();
|
|
var logger = kernel.Get<Logger<Program>>();
|
|
|
- logger.LogInformation($"Informational Message - Hello {config["Hello"]}");
|
|
|
|
|
- logger.LogWarning("Ooopsie!");
|
|
|
|
|
|
|
+ logger.LogWarning("Hello");
|
|
|
|
|
|
|
|
var rootCommand = new RootCommand()
|
|
var rootCommand = new RootCommand()
|
|
|
{
|
|
{
|