Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Examples/Cinema.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Examples
{
public class Cinema : ITicketing
{
public void Reserve() { }
}
}
7 changes: 7 additions & 0 deletions Examples/Concert.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Examples
{
public class Concert : ITicketing
{
public void Reserve() { }
}
}
7 changes: 7 additions & 0 deletions Examples/EmailService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class EmailService : INotificationService
{
public void Push(string message)
{
Console.WriteLine($"Sending Email: {message}");
}
}
7 changes: 7 additions & 0 deletions Examples/Flight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Examples
{
public class Flight : ITicketing
{
public void Reserve() { }
}
}
4 changes: 4 additions & 0 deletions Examples/INotificationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public interface INotificationService
{
void Push(string message);
}
4 changes: 4 additions & 0 deletions Examples/ITicketing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public interface ITicketing
{
public void Reserve();
}
22 changes: 11 additions & 11 deletions Examples/NotificationService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
public class NotificationService()
public class NotificationService
{
public ... Get(string type)
private readonly INotificationService _notificationService;


public NotificationService(INotificationService notificationService)
{
if (type == "Email")
return new ...();
else if (type == "SMS")
return new ...();
//else if (type == "Push")
// return new ...();
_notificationService = notificationService;
}

else
throw new ArgumentException("Invalid notification type.");
public void PushNotification(string message)
{
_notificationService.Push(message);
}
}
}
7 changes: 7 additions & 0 deletions Examples/SmsService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class SmsService : INotificationService
{
public void Push(string message)
{
Console.WriteLine($"Sending SMS: {message}");
}
}
22 changes: 11 additions & 11 deletions Examples/Ticketing.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
public class TicketService
public class Ticketing
{
public ... Get(string ticketType)
private readonly ITicketing _ticketing;

public Ticketing(ITicketing ticketing)
{
if (ticketType == "Movie")
return new ...();
else if (ticketType == "Concert")
return new ...();
else if (ticketType == "Flight")
return new ...();
else
throw new ArgumentException("Invalid ticket type.");
_ticketing = ticketing;
}
}

public void ReserveTicket()
{
_ticketing.Reserve();
}
}