public PlugInManager() { PlugInSourceList = new PlugInSourceList(); //获取Plugin目录下面的插件 string pluginSimulatorPath = System.Environment.CurrentDirectory;// + "\\Plugins\\"; DirectoryInfo dirinfo = new DirectoryInfo(pluginSimulatorPath); foreach (FileSystemInfo file in dirinfo.GetFileSystemInfos()) { if (file != null) { if (file.Extension.ToLower().Equals(".dll")) { Assembly a = Assembly.LoadFrom(file.FullName); var plugIn = (a.GetCustomAttribute(typeof(PlugInAttribute)) as PlugInAttribute); if (plugIn != null) { PlugInSourceList.Add( new PlugInSource() { Assemblie = a, PlugInType = plugIn.PlugInType, PlugInName = plugIn.Name } ); } } } } }
public static void AddFiles( [NotNull] this PlugInSourceList list, params string[] filePaths) { Check.NotNull(list, nameof(list)); list.Add(new FilePlugInSource(filePaths)); }
public static void AddTypes( [NotNull] this PlugInSourceList list, params Type[] moduleTypes) { Check.NotNull(list, nameof(list)); list.Add(new TypePlugInSource(moduleTypes)); }
public static void AddFolder( [NotNull] this PlugInSourceList list, [NotNull] string folder, SearchOption searchOption = SearchOption.TopDirectoryOnly) { Check.NotNull(list, nameof(list)); list.Add(new FolderPlugInSource(folder, searchOption)); }