Introduction:
Sometimes you want to design your classes set that interact with each other in a loosely coupled manner by keeping your classes away from referring each other directly… Mediator Design Pattern solve this issue by promoting the idea of loosely coupling classes
Example:
static void Main(string[] args) { CountryList countrylist = new CountryList(); CityList city = new CityList(); countrylist.RegisterMonitorChangers(city); Console.WriteLine(“——————-“); Console.ReadKey(); } abstract class CountryListChangesMonitorBase public abstract void RecieveChange(string countryName); class CountryList List<CountryListChangesMonitorBase> participants = new List<CountryListChangesMonitorBase>(); public CountryList() } public void SelectCountry(string countryName) foreach (CountryListChangesMonitorBase p in participants) public void RegisterMonitorChangers( CountryListChangesMonitorBase monitor) monitor.TriggerList = this; } class CityList:CountryListChangesMonitorBase class PhoneNumberTextBox: CountryListChangesMonitorBase |