AutofacSamples4 implemented

This commit is contained in:
2020-12-02 21:40:14 +01:00
parent 0588a6a224
commit 9cc7079329
3 changed files with 67 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

53
AutofacSample3/Program.cs Normal file
View File

@ -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!");
}
}
}