//Load all available plugins public void fetchPlugins(string pluginDirectory) { //Prepare a clean data Assembly currentAssembly = null; List <string> assemblyTypes = new List <string>(); pluginMetadata currentMetadata = new pluginMetadata(); loadedAssemblies = new List <Assembly>(); assembliesMetadata = new List <pluginMetadata>(); //Check if the plugins directory exist if (Directory.Exists(pluginDirectory)) { //Get all dll files from the plugins directory string[] filesInDirectory = Directory.GetFiles(pluginDirectory, "*.dll"); //Load assemblies and check if rexPluginInterface is implemented foreach (string dirFile in filesInDirectory) { currentAssembly = null; assemblyTypes = new List <string>(); currentMetadata = new pluginMetadata(); try { //Load assembly currentAssembly = Assembly.LoadFile(dirFile); //Load assembly types foreach (Type loadedTypes in currentAssembly.GetTypes()) { assemblyTypes.Add(loadedTypes.ToString()); } //Check if interface is properly implemented if (assemblyTypes.Contains("rexPluginSystem.rexPluginInterfaceV2") && assemblyTypes.Contains("rexPluginSystem.rexPlugin")) { //Add validated MemcardRex plugin to the trusted assemblies list loadedAssemblies.Add(currentAssembly); //Load plugin metadata currentMetadata.pluginName = getPluginName(loadedAssemblies.Count - 1); currentMetadata.pluginAuthor = getPluginAuthor(loadedAssemblies.Count - 1); currentMetadata.pluginSupportedGames = getPluginSupportedGames(loadedAssemblies.Count - 1); //Update global metadata assembliesMetadata.Add(currentMetadata); } } catch (Exception) { //Console.Write("rexDebug: " + ex.Message); } } } }
//Load all available plugins public void fetchPlugins(string pluginDirectory) { //Prepare a clean data Assembly currentAssembly = null; List<string> assemblyTypes = new List<string>(); pluginMetadata currentMetadata = new pluginMetadata(); loadedAssemblies = new List<Assembly>(); assembliesMetadata = new List<pluginMetadata>(); //Check if the plugins directory exist if (Directory.Exists(pluginDirectory)) { //Get all dll files from the plugins directory string[] filesInDirectory = Directory.GetFiles(pluginDirectory, "*.dll"); //Load assemblies and check if rexPluginInterface is implemented foreach(string dirFile in filesInDirectory) { currentAssembly = null; assemblyTypes = new List<string>(); currentMetadata = new pluginMetadata(); try { //Load assembly currentAssembly = Assembly.LoadFile(dirFile); //Load assembly types foreach(Type loadedTypes in currentAssembly.GetTypes()) { assemblyTypes.Add(loadedTypes.ToString()); } //Check if interface is properly implemented if(assemblyTypes.Contains("rexPluginSystem.rexPluginInterfaceV2") && assemblyTypes.Contains("rexPluginSystem.rexPlugin")) { //Add validated MemcardRex plugin to the trusted assemblies list loadedAssemblies.Add(currentAssembly); //Load plugin metadata currentMetadata.pluginName = getPluginName(loadedAssemblies.Count - 1); currentMetadata.pluginAuthor = getPluginAuthor(loadedAssemblies.Count - 1); currentMetadata.pluginSupportedGames = getPluginSupportedGames(loadedAssemblies.Count - 1); //Update global metadata assembliesMetadata.Add(currentMetadata); } } catch(Exception) { //Console.Write("rexDebug: " + ex.Message); } } } }