DesignPatternsFacade

CSharp · Console

/Program.cs

using System;

public class Connection 
{
	public void Disconnect()
	{
	}
}

public class AuthToken
{
}

public class Message
{
	public string Content {get; set;}
	
	public Message(string content)
	{
		this.Content = content;
	}
}
						   
public class NotificationServer
{
	public Connection Connect(string ipAddress)
	{
		return new Connection();
	}
	
	public AuthToken Authenticate(string appID, string key)
	{
		return new AuthToken();
	}
		
	public void Send(AuthToken token, Message message, string target)
	{
		Console.WriteLine(message.Content);
	}
}

public class NotificationService
{
	public void Send(string message, string target)
	{
		var server = new NotificationServer();
		var connection = server.Connect("ip");
		var authToken = server.Authenticate("appId", "key");
		server.Send(authToken, new Message(message), target);
	}
}
					
public class Program
{
	public static void Main()
	{
		var service = new NotificationService();
		service.Send("Hello World", "target");
	}
}
;