Skip to content

Instantly share code, notes, and snippets.

@huanlin
Created August 13, 2014 01:09
Show Gist options
  • Save huanlin/a19d470a4942fffb1788 to your computer and use it in GitHub Desktop.
Save huanlin/a19d470a4942fffb1788 to your computer and use it in GitHub Desktop.
Example code of DI book
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