Ejemplo n.º 1
0
        private static void LoadPlugins()
        {
            List <PluginServices.AvailablePlugin> pluginz =
                PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, typeof(IOMLPlugin).Name);

            // Loop through available plugins, creating instances and adding them
            foreach (PluginServices.AvailablePlugin oPlugin in pluginz)
            {
                OMLPlugin objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin);
                objPlugin.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound);
                plugins.Add(objPlugin);
            }
        }
Ejemplo n.º 2
0
        private void PrepareForm()
        {
            Application.DoEvents();
            Cursor = Cursors.WaitCursor;
            List <PluginServices.AvailablePlugin> plugins = new List <PluginServices.AvailablePlugin>();
            string path = FileSystemWalker.PluginsDirectory;

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

            // Loop through available plugins, creating instances and add them
            if (plugins != null)
            {
                string pluginForProperty = OMLEngine.Settings.SettingsManager.MetaDataMap_PluginForProperty(_propertyName);
                cbDefault.Checked = String.IsNullOrEmpty(pluginForProperty);

                Dictionary <string, object> dataCollection = new Dictionary <string, object>();
                foreach (PluginServices.AvailablePlugin oPlugin in plugins)
                {
                    // Create instance to get plugin list
                    objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);
                    try
                    {
                        foreach (MetaDataPluginDescriptor provider in objPlugin.GetProviders)
                        {
                            // 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>());

                            provider.PluginDLL.SearchForMovie(_title.Name, OMLEngine.Settings.OMLSettings.MetadataLookupResultsQty);

                            Title title = OMLSDK.SDKUtilities.ConvertOMLSDKTitleToTitle(provider.PluginDLL.GetBestMatch());
                            if (title != null)
                            {
                                AddResult(provider, _propertyInfo.GetValue(title, null), pluginForProperty);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Utilities.DebugLine("[OMLDatabaseEditor] Error loading metadata: " + e.Message);
                        continue;
                    }
                }
                plugins = null;
            }
            Cursor = Cursors.Default;
        }
Ejemplo n.º 3
0
 private static void LoadPlugins()
 {
     if (availablePlugins.Count == 0)
     {
         List <PluginServices.AvailablePlugin> Pluginz = new List <PluginServices.AvailablePlugin>();
         string path = Path.GetDirectoryName(FileSystemWalker.PluginsDirectory + @"\\Plugins");
         OMLApplication.DebugLine("Path is: " + path);
         Pluginz = PluginServices.FindPlugins(path, "OMLSDK.IOMLPlugin");
         OMLPlugin objPlugin;
         // Loop through available plugins, creating instances and adding them
         foreach (PluginServices.AvailablePlugin oPlugin in Pluginz)
         {
             objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin);
             availablePlugins.Add(objPlugin);
         }
         Pluginz = null;
     }
 }
Ejemplo n.º 4
0
        private static void LoadImportPlugins(string pluginType, List <OMLPlugin> pluginList)
        {
            pluginList.Clear();

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

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

            // Loop through available plugins, creating instances and adding them
            if (plugins != null)
            {
                foreach (PluginServices.AvailablePlugin oPlugin in plugins)
                {
                    objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin);
                    pluginList.Add(objPlugin);
                }
                plugins = null;
            }
        }
Ejemplo n.º 5
0
        private static void LoadMetadataPlugins(string pluginType, List <IOMLMetadataPlugin> 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 adding them
            if (plugins != null)
            {
                foreach (PluginServices.AvailablePlugin oPlugin in plugins)
                {
                    objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);
                    pluginList.Add(objPlugin);
                    objPlugin.Initialize(new Dictionary <string, string>());
                }
                plugins = null;
            }
        }
Ejemplo n.º 6
0
        private static bool ProcessCommandLine(string [] args)
        {
            OMLPlugin pluginToUse       = null;
            string    pluginName        = args[0].Trim();
            bool      copyImages        = true;
            string    path              = null;
            bool      clearBeforeImport = false;

            if (args.Length > 1)
            {
                path = args[1];
            }
            else
            {
                return(false);
            }

            for (int i = 2; i < args.Length; i++)
            {
                if (args[i].StartsWith(COPY_IMAGES_KEY, StringComparison.OrdinalIgnoreCase))
                {
                    if (!bool.TryParse(args[i].Substring(COPY_IMAGES_KEY.Length), out copyImages))
                    {
                        return(false);
                    }
                }
                else if (args[i].StartsWith(CLEAR_BEFORE_IMPORT_KEY, StringComparison.OrdinalIgnoreCase))
                {
                    if (!bool.TryParse(args[i].Substring(CLEAR_BEFORE_IMPORT_KEY.Length), out clearBeforeImport))
                    {
                        return(false);
                    }
                }
                else // command line argument not understood
                {
                    return(false);
                }
            }

            // Loop through available plugins to find the new we need to create
            foreach (PluginServices.AvailablePlugin plugin in
                     PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, "OMLSDK.IOMLPlugin"))
            {
                if (plugin.ClassName.Equals(pluginName, StringComparison.OrdinalIgnoreCase))
                {
                    pluginToUse            = (OMLPlugin)PluginServices.CreateInstance(plugin);
                    pluginToUse.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound);
                }
            }

            if (pluginToUse == null)
            {
                Console.WriteLine(pluginName + " was not found as a plugin. The valid plugins are:");
                Console.WriteLine("");
                foreach (PluginServices.AvailablePlugin plugin in
                         PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, typeof(IOMLPlugin).Name))
                {
                    Console.WriteLine(plugin.ClassName);
                }
            }
            else
            {
                // use the found plugin
                if (pluginToUse.IsSingleFileImporter() && !File.Exists(path))
                {
                    Console.WriteLine(pluginToUse.Name + " requires an import file which it can't find (" + path + ")");
                }
                else if (!pluginToUse.IsSingleFileImporter() && !Directory.Exists(path))
                {
                    Console.WriteLine(pluginToUse.Name + " requires an import directory which can't be found (" + path + ")");
                }
                else
                {
                    if (clearBeforeImport)
                    {
                        Console.WriteLine("Clearing out old data before import ( this can take awhile )");
                        TitleCollectionManager.DeleteAllDBData();
                    }

                    Console.WriteLine("Beginning to import titles...");

                    pluginToUse.DoWork(new string[] { path });
                    LoadTitlesIntoDatabase(pluginToUse, false, true);
                }
            }

            return(true);
        }