From e10dcfa37767fc7e05c30e2f8ada6d3640f9833e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Sun, 29 Nov 2020 14:25:32 +0100 Subject: [PATCH] instantiation of generics --- AutoFacSamles/Program.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/AutoFacSamles/Program.cs b/AutoFacSamles/Program.cs index eea8a5b..c43e57a 100644 --- a/AutoFacSamles/Program.cs +++ b/AutoFacSamles/Program.cs @@ -1,5 +1,6 @@ using Autofac; using System; +using System.Collections.Generic; namespace AutoFacSamles { @@ -77,18 +78,15 @@ namespace AutoFacSamles static void Main(string[] args) { var builder = new ContainerBuilder(); - builder.RegisterType().As(); - builder.Register( c => - new Engine(c.Resolve(), 123)); - - //builder.RegisterType(); - builder.RegisterType(); + // IList --> List + // IList --> List + builder.RegisterGeneric(typeof(List<>)).As(typeof(IList<>)); IContainer container = builder.Build(); - var car = container.Resolve(); - car.Go(); + var myList = container.Resolve>(); + Console.WriteLine(myList.GetType()); } } }