Skip to content

Instantly share code, notes, and snippets.

@huanlin
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huanlin/eaa6c3d9d9246b5ece21 to your computer and use it in GitHub Desktop.
Save huanlin/eaa6c3d9d9246b5ece21 to your computer and use it in GitHub Desktop.
Unity Example 6-1
public interface INotificationManager
{
void Notify(string to, string msg);
}
public class NotificationManager : INotificationManager
{
private readonly IMessageService _msgService = null;
// 從建構函式注入訊息服務物件。
public NotificationManager(IMessageService svc)
{
_msgService = svc;
}
// 利用訊息服務來發送訊息給指定對象。
public void Notify(string to, string msg)
{
_msgService.SendMessage(to, msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment