-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdapterDesign.cs
More file actions
34 lines (31 loc) · 1.17 KB
/
AdapterDesign.cs
File metadata and controls
34 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using static NotificationApp.FactoryDesign;
namespace NotificationApp
{
class AdapterDesign
{
// Adapter Design Pattern
class SMSSenderAdapterPattern : INotificationSender
{
private readonly SMSTypeProvider smsTypeProvider;
public SMSSenderAdapterPattern(SMSTypeProvider provider)
{
smsTypeProvider = provider;
}
public void Send(string subject, string body)
{
smsTypeProvider.SendMessage(subject, body); // Adapting or making two incompatible objects compatible to communicate
// the SMSTypeProvider's interface with INotificationSender
}
}
//SMSTypeprovider class acting as bridge to provide the message
class SMSTypeProvider
{
public void SendMessage(string subject, string body)
{
Console.WriteLine($"Selected mode is SMS \n: {subject} - {body}");
}
}
}
}
// we can similarly create an Email provider class with help of Adapter pattern to communicate with INotificationSender