//代理模式(保護模式) - 測試 public static void Main(string[] args) { Console.WriteLine("========代理模式(保護模式)測試========"); //沒使用代理 Console.WriteLine("---沒使用代理---"); Person realPerson = new PersonBean(); realPerson.setLikeCount(10); Console.WriteLine("like :" + realPerson.getLikeCount()); //使用代理 Console.WriteLine("---使用代理---"); Person proxy = new ProxyPersonBean(new PersonBean()); proxy.setLikeCount(10); Console.WriteLine("like :" + proxy.getLikeCount()); }
public ProxyPersonBean(PersonBean personBean) { this.person = personBean; }