using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 阿迪达斯
/// </summary>
public class Adidas
{
public void Serivce(string something) {
Console.WriteLine("在阿迪达斯购买了: "+something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 飞扬影城
/// </summary>
public class FeiYangMovie
{
public void Serivce(string something)
{
Console.WriteLine("在飞扬影城看了一部电影: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 国美电器
/// </summary>
public class GoMe
{
public void Serivce(string something)
{
Console.WriteLine("在国美电器 买了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 哈根达斯
/// </summary>
public class HaagenDaz
{
public void Serivce(string something)
{
Console.WriteLine("在哈根达斯 买了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 真功夫
/// </summary>
public class KungFu
{
public void Serivce(string something)
{
Console.WriteLine("在真功夫 吃了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 六福珠宝
/// </summary>
public class LukFook
{
public void Serivce(string something)
{
Console.WriteLine("在六福珠宝 买了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 耐克
/// </summary>
public class NIKE
{
public void Serivce(string something)
{
Console.WriteLine("在耐克店 买了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// ONLY时装
/// </summary>
public class ONLY
{
public void Serivce(string something)
{
Console.WriteLine("在ONLY时装 买了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 苏宁电器
/// </summary>
public class Suning
{
public void Serivce(string something)
{
Console.WriteLine("在苏宁电器 买了: " + something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// Veromoda国际时装品牌
/// </summary>
public class Veromoda
{
public void Serivce(string something)
{
Console.WriteLine(something);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 消费店子
/// </summary>
public enum ShopOption
{
Adidas = 1, DKNY = 2, GoMe = 3,
NIKE = 4, Suning = 5, Veromoda = 6,
FeiYangMovie = 7, HaagenDaz = 8, LukFook = 9, KungFu = 10
}
/// <summary>
/// 消费单
/// </summary>
public class Bill {
/// <summary>
/// 要去的消费店
/// </summary>
public ShopOption Item { get; set; }
/// <summary>
/// 去这个店要买啥
/// </summary>
public string Something { get; set; }
}
public class Consumer
{
/// <summary>
/// 消费单
/// </summary>
public IList<Bill> Items { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace Com.Design.Gof.Facade
{
/// <summary>
/// 天河城
/// </summary>
public class TeeMall
{
private static readonly Assembly assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + @"\Com.Design.Gof.dll");
/// <summary>
/// 一站式服务
/// </summary>
/// <param name="consumer"></param>
public void OfferService(Consumer consumer) {
Console.WriteLine("我是: " + consumer.Name+",不差钱,今天来天河城玩: ");
Console.WriteLine("----------------------------------------------");
foreach (Bill item in consumer.Items)
{
object obj= assembly.CreateInstance("Com.Design.Gof.Facade." + item.Item);
MethodInfo info = obj.GetType().GetMethod("Serivce");
info.Invoke(obj, new object[] { item.Something });
}
Console.WriteLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.Design.Gof.Facade;
namespace Com.Design.Gof.Test
{
class Program
{
static void Main(string[] args)
{
//天河城购物中心
TeeMall TeeMall = new TeeMall();
//消费者 1
Consumer consumer = new Consumer
{
Name="聂小倩",
//消费单
Items = new List<Bill> {
new Bill{ Item=ShopOption.Adidas, Something="运动服"},
new Bill{ Item=ShopOption.GoMe, Something="苹果IPhone智能手机"},
new Bill{ Item=ShopOption.FeiYangMovie, Something="<冰河世纪 4>"},
new Bill{ Item=ShopOption.KungFu, Something="香菇炖鸡"},
new Bill{ Item=ShopOption.LukFook, Something="金项链"},
}
};
TeeMall.OfferService(consumer);
//消费者 2
consumer = new Consumer
{
Name = "宁采臣",
//消费单
Items = new List<Bill> {
new Bill{ Item=ShopOption.FeiYangMovie, Something="《太空一号》"},
new Bill{ Item=ShopOption.Veromoda, Something="然后去了Veromoda时装,买了一套服装"},
new Bill{ Item=ShopOption.HaagenDaz, Something="买了一雪糕"},
new Bill{ Item=ShopOption.Suning, Something="在苏宁看买平板电脑"},
}
};
TeeMall.OfferService(consumer);
Console.ReadKey();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有