Skip to content

Instantly share code, notes, and snippets.

@fredrikhr
Last active April 15, 2019 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrikhr/7104b41202ee885c7de8d72b67d77407 to your computer and use it in GitHub Desktop.
Save fredrikhr/7104b41202ee885c7de8d72b67d77407 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.3.100.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
</ItemGroup>
</Project>
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace DICliTest
{
public static class Program
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true)
.Build();
var services = new ServiceCollection()
.AddSingleton<IConfiguration>(config)
.AddTransient<Startup>()
;
var diContainer = services.BuildServiceProvider();
var app = diContainer.GetService<Startup>();
app.Run();
}
}
}
using Microsoft.Extensions.Configuration;
namespace DICliTest
{
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void Run()
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment