AutofacSamples4 implemented
This commit is contained in:
@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFacSamples2", "AutoFacS
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacSamples3", "AutofacSamples3\AutofacSamples3.csproj", "{4EE75D74-3696-41D7-A5D0-A128956FBCBB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacSamples3", "AutofacSamples3\AutofacSamples3.csproj", "{4EE75D74-3696-41D7-A5D0-A128956FBCBB}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacSamples4", "AutofacSample3\AutofacSamples4.csproj", "{9F3E52C4-985F-47FD-9949-B5539200069F}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{4EE75D74-3696-41D7-A5D0-A128956FBCBB}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
8
AutofacSample3/AutofacSamples4.csproj
Normal file
8
AutofacSample3/AutofacSamples4.csproj
Normal 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
53
AutofacSample3/Program.cs
Normal 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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user