-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactoryDesign.cs
45 lines (41 loc) · 1.18 KB
/
FactoryDesign.cs
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
35
36
37
38
39
40
41
42
43
44
45
using System;
namespace NotificationApp
{
class FactoryDesign
{
// Factory Design Pattern
public interface INotificationSender
{
void Send(string subject, string body);
}
class SendEmail : INotificationSender
{
public void Send(string subject, string body)
{
Console.WriteLine($"\nSelected Mode is Email {subject} - {body}");
}
}
class SendSMS : INotificationSender
{
public void Send(string subject, string body)
{
Console.WriteLine($"\nSelected Mode is SMS {subject} - {body}");
}
}
public class FactoryofNotificationSendType
{
public INotificationSender CreateNotificationSendType(string mode)
{
switch (mode)
{
case "email":
return new SendEmail();
case "sms":
return new SendSMS();
default:
throw new Exception("Invalid notification mode");
}
}
}
}
}