- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Reflection;
- using System.Configuration;
- namespace ConsoleApplication1
- {
- internal interface SportMan
- {
- void Come();
- }
- class ChineseSportMan : SportMan
- {
- public void Come()
- {
- Console.WriteLine("中国运动员来了~~~");
- }
- }
- class RussianSportMan : SportMan
- {
- public void Come()
- {
- Console.WriteLine("俄罗斯运动员来了~~~");
- }
- }
- class TheController
- {
- public static SportMan CreateSportMan()
- {
- //string s = (string)ConfigurationSettings.AppSettings["Nation"];
- return (SportMan)Assembly.Load("ConsoleApplication1").CreateInstance("ConsoleApplication1."+ConfigurationSettings.AppSettings["Nation"].ToString());
- //ConfigurationSettings.AppSettings[];
- //return new ChineseSportMan();
- }
- }
- class Client
- {
- public static void Main()
- {
- TheController.CreateSportMan().Come();
- //s.Come();
- //SportMan c=(SportMan)Assembly.Load("ConsoleApplication1").CreateInstance("ConsoleApplication1.ChineseSportMan");
- //c.Come();
- }
- }
- }
![设计模式---抽象工厂模式+反射+配置文件](https://p-blog.csdn.net/images/p_blog_csdn_net/cuipengfei1/EntryImages/20080808/ClassDiagram1.jpg)