File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
Expand file tree Collapse file tree 3 files changed +40
-0
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ public interface INotification
2+ {
3+ void Send ( string message ) ;
4+ }
5+
6+ public class EmailNotification : INotification
7+ {
8+ public void Send ( string message ) => Console . WriteLine ( $ "Email sent: { message } ") ;
9+ }
10+
11+ public class SmsNotification : INotification
12+ {
13+ public void Send ( string message ) => Console . WriteLine ( $ "SMS sent: { message } ") ;
14+ }
15+
16+ #region Thid block of code is not in your code base, it is a library(3rd party)
17+ public class SlackNotification
18+ {
19+ public void PostMessageToChannel ( string channel , string message )
20+ {
21+ Console . WriteLine ( $ "Message sent to Slack channel { channel } : { message } ") ;
22+ }
23+ }
24+ #endregion
25+
26+ public class NotificationService ( )
27+ {
28+ public ... Get ( string type )
29+ {
30+ if ( type == "Email" )
31+ return new ... ( ) ;
32+ else if ( type == "SMS" )
33+ return new ... ( ) ;
34+ else if ( type == "Slack" )
35+ return new ... ( ) ;
36+
37+ else
38+ throw new ArgumentException ( "Invalid notification type." ) ;
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments