This project has moved and is read-only. For the latest updates, please go here.

Free Plugin Management Library

Jul 12, 2015 at 8:13 AM
Edited Jul 12, 2015 at 8:17 AM
Hello.

I'm contributing this library to the community. One of the fundamental things that you will want to do if you want to host VSTS is to scan through the VSTs that exist on a user's hard drive. This library will do this for you. It takes some time depending on the speed of the computer, so it raises events along the way so that you can display progress. Lastly, it writes the plugin info to an XML file so that you can reload the list of plugins later.

Thanks to Yury for some code snippets..

Download link:
https://onedrive.live.com/redir?resid=47321C0630B57E1D!4941&authkey=!AFNCnDLB0-2R-WQ&ithint=file%2c7z

Code Sample:
       private void ScanPlugins_Click(object sender, RoutedEventArgs e)
        {
            ScanProgressBar.Value = 0;

            var bgWorker = new BackgroundWorker();
            bgWorker.DoWork += (s, e2) =>
            {
                var pluginScanner = new PluginScanner(Globals.PluginPath, _MySynthHostCommandStubAdapter, true);
                pluginScanner.PluginCountLoaded += PluginScanner_PluginCountLoaded;
                pluginScanner.PluginScanned += PluginScanner_PluginScanned;
                pluginScanner.Scan();
                pluginScanner.WriteToFile(Path.Combine(Globals.MySynthPath, "PluginList.xml"));
            };

            bgWorker.RunWorkerCompleted += (s, e2) =>
            {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    DiplayPlugins();
                }));
            };

            bgWorker.RunWorkerAsync();
        }

        private void PluginScanner_PluginCountLoaded(object sender, PluginScanner.PluginCountLoadedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                ScanProgressBar.Maximum = e.PluginCount;
            }));
        }

        private void PluginScanner_PluginScanned(object sender, PluginScanner.PluginScannedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                ScanProgressBar.Value++;

                if (e.IsSuccess)
                {
                    ScannedPluginBox.Text = e.PluginDetails.Name + " Scanned";
                }
                else
                {
                    ScannedPluginBox.Text = e.FailedPluginPath + " Failed";
                }

            }));

        }
PS: I will be refactoring this library over time for my own use. I may or may not provide an update in time, but no promises.
Jul 12, 2015 at 1:19 PM
If you're working on a lot of files, you'd want to filter files using the Windows shell through the Search Pattern parameter of GetFiles instead of getting all files and relying on the 'Foreach-If Antipattern'.
           foreach (var fileName in Directory.GetFiles(path))
            {
                if (Path.GetExtension(fileName).ToLower() == ".dll")
                {
                    pluginPaths.Add(Path.Combine(path, fileName));
                }
            }
           foreach (String fileName in Directory.GetFiles(path, "*.dll"))
                    pluginPaths.Add(Path.Combine(path, fileName));
Jul 13, 2015 at 12:39 AM
Didn't anyone ever tell you that premature optimisation ruins the fun?
Aug 2, 2015 at 8:54 AM
Thanx!

I will look at it.