diff --git a/AutoFacSamles.sln b/AutoFacSamles.sln index 3c1de9c..7e30169 100644 --- a/AutoFacSamles.sln +++ b/AutoFacSamles.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFacSamples2", "AutoFacS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacSamples3", "AutofacSamples3\AutofacSamples3.csproj", "{4EE75D74-3696-41D7-A5D0-A128956FBCBB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacSamples4", "AutofacSample3\AutofacSamples4.csproj", "{9F3E52C4-985F-47FD-9949-B5539200069F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,10 @@ Global {4EE75D74-3696-41D7-A5D0-A128956FBCBB}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EE75D74-3696-41D7-A5D0-A128956FBCBB}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EE75D74-3696-41D7-A5D0-A128956FBCBB}.Release|Any CPU.Build.0 = Release|Any CPU + {9F3E52C4-985F-47FD-9949-B5539200069F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F3E52C4-985F-47FD-9949-B5539200069F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F3E52C4-985F-47FD-9949-B5539200069F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F3E52C4-985F-47FD-9949-B5539200069F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AutofacSample3/AutofacSamples4.csproj b/AutofacSample3/AutofacSamples4.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/AutofacSample3/AutofacSamples4.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/AutofacSample3/Program.cs b/AutofacSample3/Program.cs new file mode 100644 index 0000000..4fe8fa2 --- /dev/null +++ b/AutofacSample3/Program.cs @@ -0,0 +1,53 @@ +using System; + +namespace AutofacSamples4 +{ + + public interface ILog + { + void Write(string message); + } + + public class ConsoleLog : ILog + { + public ConsoleLog() + { + Console.WriteLine($"Console log created at {DateTime.Now.Ticks}"); + } + public void Write(string message) + { + Console.WriteLine(message); + } + + public void Dispose() + { + Console.WriteLine($"Console logger no longer required"); + } + + } + + public class SMSLog : ILog + { + private readonly string phoneNumber; + + public SMSLog(string phoneNumber) + { + this.phoneNumber = phoneNumber; + } + public void Write(string message) + { + Console.WriteLine($"SMS to {phoneNumber} : {message}"); + } + public void Dispose() + { + } + } + + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +}