Skip to content

Commit 7b08cf5

Browse files
committed
adapter
1 parent a6b4b5b commit 7b08cf5

File tree

8 files changed

+134
-0
lines changed

8 files changed

+134
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin
2+
obj
3+
.vs

adapter/Adapter.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31005.135
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{FF981F27-FF70-4EB4-BD4C-E0DC7B51D945}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FF981F27-FF70-4EB4-BD4C-E0DC7B51D945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FF981F27-FF70-4EB4-BD4C-E0DC7B51D945}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FF981F27-FF70-4EB4-BD4C-E0DC7B51D945}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{FF981F27-FF70-4EB4-BD4C-E0DC7B51D945}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {17429E3D-68F9-4F86-9D22-AF18946362AB}
24+
EndGlobalSection
25+
EndGlobal

adapter/Adapter/Adapter.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="SendGrid" Version="9.22.0" />
10+
</ItemGroup>
11+
12+
</Project>

adapter/Adapter/ClassAdapter.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Adapter.business_logic;
2+
using SendGrid;
3+
using SendGrid.Helpers.Mail;
4+
using System.Threading.Tasks;
5+
6+
namespace Adapter
7+
{
8+
public class ClassAdapter : SendGridClient, IUserNotificationService
9+
{
10+
public ClassAdapter(SendGridClientOptions options) : base(options)
11+
{
12+
}
13+
14+
public Task NotifyUser(string userId, string message)
15+
{
16+
return SendEmailAsync(new SendGridMessage());
17+
}
18+
}
19+
}

adapter/Adapter/ObjectAdapter.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Adapter.business_logic;
2+
using SendGrid;
3+
using SendGrid.Helpers.Mail;
4+
using System.Threading.Tasks;
5+
6+
namespace Adapter
7+
{
8+
public class ObjectAdapter : IUserNotificationService
9+
{
10+
private readonly SendGridClient client;
11+
12+
public ObjectAdapter(SendGridClient client)
13+
{
14+
this.client = client;
15+
}
16+
17+
public Task NotifyUser(string userId, string message)
18+
{
19+
return client.SendEmailAsync(new SendGridMessage());
20+
}
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using SendGrid;
2+
using SendGrid.Helpers.Mail;
3+
using System.Threading.Tasks;
4+
5+
namespace Adapter.business_logic
6+
{
7+
public class BitcoinEvent
8+
{
9+
private readonly IUserNotificationService userNF;
10+
11+
public BitcoinEvent(IUserNotificationService userNF)
12+
{
13+
this.userNF = userNF;
14+
}
15+
16+
public Task Execute()
17+
{
18+
// other work here
19+
return userNF.NotifyUser("", "");
20+
}
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using SendGrid;
2+
using SendGrid.Helpers.Mail;
3+
using System.Threading.Tasks;
4+
5+
namespace Adapter.business_logic
6+
{
7+
public class EmployeeFiredEvent
8+
{
9+
private readonly IUserNotificationService userNF;
10+
11+
public EmployeeFiredEvent(IUserNotificationService userNF)
12+
{
13+
this.userNF = userNF;
14+
}
15+
16+
public Task Execute()
17+
{
18+
// other work here
19+
return userNF.NotifyUser("", "");
20+
}
21+
}
22+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Threading.Tasks;
2+
3+
namespace Adapter.business_logic
4+
{
5+
public interface IUserNotificationService
6+
{
7+
Task NotifyUser(string userId, string message);
8+
}
9+
}

0 commit comments

Comments
 (0)