示例#1
0
        // Not putting a static on this as it doesn't seem to like a static event
        public void LoadMetadataPlugins(string pluginType, List <MetaDataPluginDescriptor> pluginList)
        {
            pluginList.Clear();

            List <PluginServices.AvailablePlugin> plugins = new List <PluginServices.AvailablePlugin>();
            string path = FileSystemWalker.PluginsDirectory;

            plugins = PluginServices.FindPlugins(path, pluginType);
            IOMLMetadataPlugin objPlugin;

            // Loop through available plugins, creating instances and add them
            if (plugins != null)
            {
                foreach (PluginServices.AvailablePlugin oPlugin in plugins)
                {
                    // Create an instance to enumerate providers in the plugin
                    objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);

                    foreach (MetaDataPluginDescriptor provider in objPlugin.GetProviders)
                    {
                        if (Loaded != null)
                        {
                            Loaded(provider.DataProviderName);
                        }

                        // Create instance of the plugin for this particular provider. This would create a unique instance per provider.
                        provider.PluginDLL = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);

                        // Initialise the plugin and select which provider it serves
                        provider.PluginDLL.Initialize(provider.DataProviderName, new Dictionary <string, string>());

                        // Configure the plugin with any settings stored in the db
                        if (provider.PluginDLL.GetOptions() != null)
                        {
                            foreach (OMLMetadataOption option in provider.PluginDLL.GetOptions())
                            {
                                string setting = OMLEngine.Settings.SettingsManager.GetSettingByName(option.Name, "PLG-" + provider.DataProviderName);
                                if (setting != null)
                                {
                                    provider.PluginDLL.SetOptionValue(option.Name, setting);
                                }
                            }
                        }
                        pluginList.Add(provider);
                    }
                }
                plugins = null;
            }
        }
        public DirectoryScanner()
        {
            timer = new System.Timers.Timer();
            timer.AutoReset = false;
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);

            badWatcherTimer = new System.Timers.Timer();
            badWatcherTimer.AutoReset = false;
            badWatcherTimer.Interval = CHANGE_TIMER_TIMEOUT;
            badWatcherTimer.Elapsed += new System.Timers.ElapsedEventHandler(badWatcherTimer_Elapsed);

            // Load the plugins
            _metadataPlugins = new List<MetaDataPluginDescriptor>();
            PluginServices plg = new PluginServices();
            plg.LoadMetadataPlugins(PluginTypes.MetadataPlugin, _metadataPlugins);
        }
示例#3
0
        /// <summary>
        /// Load metadata plugins
        /// </summary>
        /// <param name="pluginType"></param>
        /// <param name="pluginList"></param>
        private void LoadMetadataPlugins(string pluginType, List<MetaDataPluginDescriptor> pluginList)
        {
            PluginServices pgs = new PluginServices();
            pgs.Loaded += new PluginServices.PluginLoaded(MetadataPluginLoaded);
            pgs.LoadMetadataPlugins(pluginType, pluginList);

            /*pluginList.Clear();

            List<PluginServices.AvailablePlugin> plugins = new List<PluginServices.AvailablePlugin>();
            string path = FileSystemWalker.PluginsDirectory;
            plugins = PluginServices.FindPlugins(path, pluginType);
            IOMLMetadataPlugin objPlugin;
            // Loop through available plugins, creating instances and add them
            if (plugins != null)
            {
                foreach (PluginServices.AvailablePlugin oPlugin in plugins)
                {
                    // Create an instance to enumerate providers in the plugin
                    objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);

                    foreach (MetaDataPluginDescriptor provider in objPlugin.GetProviders)
                    {
                        SplashScreen2.SetStatus(32, "Loading plugin - " + provider.DataProviderName);

                        // Create instance of the plugin for this particular provider. This would create a unique instance per provider.
                        provider.PluginDLL = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);

                        // Initialise the plugin and select which provider it serves
                        provider.PluginDLL.Initialize(provider.DataProviderName, new Dictionary<string, string>());

                        // Configure the plugin with any settings stored in the db
                        if (provider.PluginDLL.GetOptions() != null)
                        {
                            foreach (OMLMetadataOption option in provider.PluginDLL.GetOptions())
                            {
                                string setting = OMLEngine.Settings.SettingsManager.GetSettingByName(option.Name, "PLG-" + provider.DataProviderName);
                                if (setting != null)
                                {
                                    provider.PluginDLL.SetOptionValue(option.Name, setting);
                                }
                            }
                        }

                        pluginList.Add(provider);
                    }

                }
                plugins = null;
            }*/
        }