changed to .NET5 , + Property injection

This commit is contained in:
2020-11-29 21:15:45 +01:00
parent 5ca347fc6a
commit e2027a5f7e
6 changed files with 59 additions and 6 deletions

View File

@ -0,0 +1,35 @@
using Autofac;
using System;
namespace AutoFacSamples2
{
public class Parent
{
public override string ToString()
{
return "I am your father";
}
}
public class Child
{
public string Name { get; set; }
public Parent Parent { get; set; }
}
internal class Program
{
static void Main(string[] args)
{
var builder = new ContainerBuilder();
builder.RegisterType<Parent>();
builder.RegisterType<Child>().PropertiesAutowired();
var container = builder.Build();
var parent = container.Resolve<Child>().Parent;
Console.WriteLine(parent);
}
}
}