1.定义接口
public interface IPayGateway
{
void unifiedorder();
void refund();
void query();
void sendRedPack();
}
2.定义适配器
using System;
using System.Collections.Generic;
using System.Text;
namespace adapter
{
public class PayGatewayAdapter : IPayGateway
{
public virtual void unifiedorder()
{
throw new NotImplementedException();
}
public virtual void refund()
{
throw new NotImplementedException();
}
public virtual void query()
{
throw new NotImplementedException();
}
public virtual void sendRedPack()
{
throw new NotImplementedException();
}
}
}
3.定义普通视频会员
using System;
using System.Collections.Generic;
using System.Text;
namespace adapter
{
public class ProductVideoOrder : PayGatewayAdapter
{
public override void unifiedorder()
{
System.Console.WriteLine("ProductVideoOrder unifiedorder");
}
public override void refund()
{
System.Console.WriteLine("ProductVideoOrder refund");
}
}
}
4.定义VIP视频会员
using System;
using System.Collections.Generic;
using System.Text;
namespace adapter
{
public class ProductVipOrder : PayGatewayAdapter
{
public override void unifiedorder()
{
System.Console.WriteLine("ProductVipOrder unifiedorder");
}
public override void refund()
{
System.Console.WriteLine("ProductVipOrder refund");
}
public override void sendRedPack()
{
System.Console.WriteLine("ProductVipOrder SendRedPack");
}
}
}
5.主函数
using System;
namespace adapter
{
public interface IPayGateway
{
void unifiedorder();
void refund();
void query();
void sendRedPack();
}
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("-----------------");
System.Console.WriteLine("普通会员拥有的函数");
ProductVideoOrder videoOrder = new ProductVideoOrder();
videoOrder.unifiedorder();
videoOrder.refund();
System.Console.WriteLine("-----------------");
System.Console.WriteLine("VIP会员拥有的函数");
ProductVipOrder vipOrder = new ProductVipOrder();
vipOrder.unifiedorder();
vipOrder.refund();
vipOrder.sendRedPack();
}
}
}