public void Events() { var button = new DelegateButton(); button.Click += delegate { Console.WriteLine("Pressed!"); }; button.Press(); }
public void EncapsulationIssue_1() { var button = new DelegateButton(); button.Click += delegate { Console.WriteLine("Pressed!"); }; //Malicious Code button.Click.Invoke(); }
public void EncapsulationIssue_2() { var button = new DelegateButton(); button.Click += delegate { Console.WriteLine("Do Something Important"); }; //Malicious Code button.Click = delegate { Console.WriteLine("Do Nothing"); }; button.Press(); }