From 1ad11fd25fe96a201168808ba9faf071db56fb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Sat, 28 Nov 2020 16:30:12 +0100 Subject: [PATCH] first use of autofac --- AutoFacSamles/AutoFacSamles.csproj | 4 ++++ AutoFacSamles/Program.cs | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/AutoFacSamles/AutoFacSamles.csproj b/AutoFacSamles/AutoFacSamles.csproj index c73e0d1..d1ec505 100644 --- a/AutoFacSamles/AutoFacSamles.csproj +++ b/AutoFacSamles/AutoFacSamles.csproj @@ -5,4 +5,8 @@ netcoreapp3.1 + + + + diff --git a/AutoFacSamles/Program.cs b/AutoFacSamles/Program.cs index 4dfc66a..2fcb338 100644 --- a/AutoFacSamles/Program.cs +++ b/AutoFacSamles/Program.cs @@ -1,4 +1,5 @@ -using System; +using Autofac; +using System; namespace AutoFacSamles { @@ -53,9 +54,14 @@ namespace AutoFacSamles { static void Main(string[] args) { - var log = new ConsoleLog(); - var engine = new Engine(log); - var car = new Car(engine, log); + var builder = new ContainerBuilder(); + builder.RegisterType().As(); + builder.RegisterType(); + builder.RegisterType(); + + IContainer container = builder.Build(); + + var car = container.Resolve(); car.Go(); } }