public override void BuyProduct() { ProBuy(); if (realBuyPerson == null) { realBuyPerson = new RealBuyPerson(); } realBuyPerson.BuyProduct(); }
public override void BuyProduct() { Console.WriteLine("通过代理类访问真实实体对象的方法"); if (_realSubject == null) { _realSubject = new RealBuyPerson(); } this.PreBuyProduct(); // 调用真实主题方法 _realSubject.BuyProduct(); this.PostBuyProduct(); }