diff --git a/AutoFacSamles.sln b/AutoFacSamles.sln index ae24021..4da1c53 100644 --- a/AutoFacSamles.sln +++ b/AutoFacSamles.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFacSamles", "AutoFacSam EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "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}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {D8041EF1-F2AC-4A04-A7A5-56E2CB6F249C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8041EF1-F2AC-4A04-A7A5-56E2CB6F249C}.Release|Any CPU.ActiveCfg = Release|Any CPU {D8041EF1-F2AC-4A04-A7A5-56E2CB6F249C}.Release|Any CPU.Build.0 = Release|Any CPU + {2152A909-E97C-453A-8A6C-869F7987D7B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PatternDemo2/PatternDemoCore2.csproj b/PatternDemo2/PatternDemoCore2.csproj new file mode 100644 index 0000000..d1ec505 --- /dev/null +++ b/PatternDemo2/PatternDemoCore2.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/PatternDemo2/Program.cs b/PatternDemo2/Program.cs new file mode 100644 index 0000000..232b0a1 --- /dev/null +++ b/PatternDemo2/Program.cs @@ -0,0 +1,46 @@ +using Autofac; +using System; + +namespace PatternDemoCore +{ + + public class Entity + { + private static Random random = new Random(); + private int number; + + public Entity() + { + number = random.Next(); + } + + public override string ToString() + { + return $"test {number}"; + } + } + + public class ViewModel + { + private readonly IContainer container; + + public ViewModel(IContainer container) + { + this.container = container; + } + + public void Method() + { + var entity = container.Resolve(); + } + } + + + public class Demo + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +}