您现在的位置是:主页 > news > 做照片的ppt模板下载网站/友情链接导航

做照片的ppt模板下载网站/友情链接导航

admin2025/5/6 4:20:53news

简介做照片的ppt模板下载网站,友情链接导航,11月达感染高峰,西部数码个人网站c#: 子游戏 ,编译为 一个 一个 的 dll. 而 游戏 管理 中心 。就是界面 程序 。可以 加载 任何游戏 插件 ,只要 实现 了 子游戏 接口。 原来 看 c 写的 比较 复杂 。在c#中 真的是 非常 简便了 。超级简单。 游戏管理中心 。 using System; …

做照片的ppt模板下载网站,友情链接导航,11月达感染高峰,西部数码个人网站c#: 子游戏 ,编译为 一个 一个 的 dll. 而 游戏 管理 中心 。就是界面 程序 。可以 加载 任何游戏 插件 ,只要 实现 了 子游戏 接口。 原来 看 c 写的 比较 复杂 。在c#中 真的是 非常 简便了 。超级简单。 游戏管理中心 。 using System; …

c#:

子游戏 ,编译为 一个 一个 的  dll. 而 游戏 管理 中心 。就是界面 程序 。可以 加载 任何游戏 插件 ,只要 实现 了 子游戏 接口。

原来 看  c++ 写的 比较 复杂 。在c#中 真的是 非常 简便了 。超级简单。

 

游戏管理中心 。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;namespace helloworld
{public interface  Game_Interface{string GameName();void Start();void End();}public class GameCenter{List<Game_Interface> Games;public GameCenter(){Games = new List<Game_Interface>();}public void StartGames(){//模拟从xml配置文档,读出了游戏名字。//string game1name = getnameFormxml();List<string> gamenames=new List<string>();gamenames.Add("Game_land");gamenames.Add("Game_machong");foreach(string gamename in gamenames){Assembly tempAss = Assembly.Load(gamename);//根据程序集名字装载程序集.xxx.dll
Type temptype = null;// object obj = CreateInstance1(tempAss, "subgame." + gamename, out temptype);//一般2种方法得到一个类的实例和类型信息.  1通过指定命名空间加类名 xxx.xxxobject obj = CreateInstance2(tempAss, typeof(Game_Interface),out temptype);//2.通过查看某些属性。如这里是查看是否有实现了某个接口的类。
MethodInfo m1 = temptype.GetMethod("Start");//调用方法可以有2种方式  1.继续反射。从对象中。手工调用某个方法。m1.Invoke(obj, null);Game_Interface tempGame = obj as Game_Interface;//2.如果是实现了某个接口.那么可以转为接口类型.一般采用这种,强类型肯定比手工写方法名字 更安全。if(tempGame!=null){tempGame.Start();}}}object CreateInstance1(Assembly tempAss, string typename,out Type mytype){Type temptype = tempAss.GetType(typename);//"subgame." + gamenameobject obj = Activator.CreateInstance(temptype);//从程序集中,根据命名空间和类名组成的全地址,实力化一个对象出来。mytype = temptype;return obj;}object CreateInstance2(Assembly tempAss, Type interfacetype, out Type mytype){Type[] alltypes = tempAss.GetTypes();Type wantType = null;for (int i = 0; i < alltypes.Length;i++ ){Type itype= alltypes[i].GetInterface("Game_Interface");//看看有没有接口类型。返回的只是接口类型而已。if (itype != null){wantType = alltypes[i];//这个才是实现了接口的类型。break;}}if (wantType != null){object obj = Activator.CreateInstance(wantType);mytype = wantType;return obj;}else{mytype = null;return null;}}public void StopGame(int gameIndex){}public void CreatRound(int gameIndex){}}
}

 

 

子 游戏 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace subgame
{public class Game_machong:helloworld.Game_Interface{public string gamename = "machong";public string GameName(){return gamename;}public void Start(){Console.WriteLine("Start machong");}public void End(){Console.WriteLine("End machong");}}
}

 

子游戏 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace subgame
{public class Game_land:helloworld.Game_Interface{public string gamename = "land";public string GameName(){return gamename;}public void Start(){Console.WriteLine("Start land");}public void End(){Console.WriteLine("End land");}}
}

 

转载于:https://www.cnblogs.com/lsfv/p/9607826.html