changed to .NET5 , + Property injection
This commit is contained in:
@ -3,11 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30717.126
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFacSamles", "AutoFacSamles\AutoFacSamles.csproj", "{2CFA4809-16F7-4DB9-B4BB-CF60945656E5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFacSamles", "AutoFacSamles\AutoFacSamles.csproj", "{2CFA4809-16F7-4DB9-B4BB-CF60945656E5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatternDemoCore", "PatternDemoCore\PatternDemoCore.csproj", "{D8041EF1-F2AC-4A04-A7A5-56E2CB6F249C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatternDemoCore", "PatternDemoCore\PatternDemoCore.csproj", "{D8041EF1-F2AC-4A04-A7A5-56E2CB6F249C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatternDemoCore2", "PatternDemo2\PatternDemoCore2.csproj", "{2152A909-E97C-453A-8A6C-869F7987D7B5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatternDemoCore2", "PatternDemo2\PatternDemoCore2.csproj", "{2152A909-E97C-453A-8A6C-869F7987D7B5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFacSamples2", "AutoFacSamples2\AutoFacSamples2.csproj", "{0EB88BA8-3B88-4142-A6D3-07F72120488D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -27,6 +29,10 @@ Global
|
||||
{2152A909-E97C-453A-8A6C-869F7987D7B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2152A909-E97C-453A-8A6C-869F7987D7B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2152A909-E97C-453A-8A6C-869F7987D7B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0EB88BA8-3B88-4142-A6D3-07F72120488D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0EB88BA8-3B88-4142-A6D3-07F72120488D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0EB88BA8-3B88-4142-A6D3-07F72120488D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0EB88BA8-3B88-4142-A6D3-07F72120488D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
12
AutoFacSamples2/AutoFacSamples2.csproj
Normal file
12
AutoFacSamples2/AutoFacSamples2.csproj
Normal file
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
35
AutoFacSamples2/Program.cs
Normal file
35
AutoFacSamples2/Program.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user