1、数码产品 销售
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace proxy
{
interface IDigitalSell
{
void Sell();
}
}
2、真实销售厂商
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace proxy
{
class DigitalSellReal : IDigitalSell
{
public void Sell()
{
Console.WriteLine("==== 厂商销售手机 ====");
Console.WriteLine("销售华为手机");
}
}
}
3、销售代理
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace proxy
{
class DigitalSellProxy : IDigitalSell
{
private IDigitalSell digitalSellReal = new DigitalSellReal();
public void Sell()
{
Console.WriteLine("=== 代理销售手机 === ");
makeAddress();
digitalSellReal.Sell()
makeAD();
}
private void makeAddress()
{
Console.WriteLine("一个好的地址");
}
private void makeAD()
{
Console.WriteLine("做个广告");
}
}
}
4、调用与使用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace proxy
{
class Program
{
static void Main(string[] args)
{
IDigitalSell realObj = new DigitalSellReal();
realObj.Sell();
Console.WriteLine("-------------------------------------------------------");
IDigitalSell proxyObj = new DigitalSellProxy();
proxyObj.Sell();
Console.ReadLine();
}
}
}