Created
August 13, 2014 01:09
-
-
Save huanlin/a19d470a4942fffb1788 to your computer and use it in GitHub Desktop.
Example code of DI book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IMessageService | |
{ | |
void Send(User user, string msg); | |
} | |
class EmailService : IMessageService | |
{ | |
public void Send(User user, string msg) | |
{ | |
// 寄送電子郵件給指定的 user (略) | |
Console.WriteLine("寄送電子郵件給使用者,訊息內容:" + msg); | |
} | |
} | |
class ShortMessageService : IMessageService | |
{ | |
public void Send(User user, string msg) | |
{ | |
// 發送簡訊給指定的 user (略) | |
Console.WriteLine("發送簡訊給使用者,訊息內容:" + msg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment