Beispiel #1
0
 public static void write(string info, iBilibilidanPlugin p)
 {
     if (main == null)
     {
         return;
     }
     main.write(p.name, info, 6);
 }
Beispiel #2
0
        internal static void load(MainWindow win)
        {
            main = win;
            string path = Path.Combine(System.Environment.CurrentDirectory, "plugin");

            if (!Directory.Exists(path))
            {
                win.write("没有发现插件目录");
                return;
            }
            string[] pluginsName = Directory.GetFiles(path, "*.dll");
            Type     myType      = typeof(iBilibilidanPlugin);

            foreach (string pluginPath in pluginsName)
            {
                Assembly ass = Assembly.LoadFile(pluginPath);
                Type[]   type;
                try{
                    type = ass.GetExportedTypes();
                }
                catch (Exception)
                {
                    win.write("无法兼容模块(已抛弃,请检查插件是否过旧)" + pluginPath);
                    continue;
                }
                foreach (Type cla in type)
                {
                    if (myType.IsAssignableFrom(cla) && !cla.IsAbstract)
                    {
                        iBilibilidanPlugin p = (iBilibilidanPlugin)Activator.CreateInstance(cla);
                        plugins.Add(p);
                    }
                }
            }
            win.write("共载入" + pluginsName.Length + "个模块,识别出" + plugins.Count + "个插件");
        }
Beispiel #3
0
		public static void write(string info,iBilibilidanPlugin p){
			if (main == null) return;
			main.write(p.name,info,6);
		}