FlatRedBall.Glue.Plugins.PluginManagerBase.CreateCatalog C# (CSharp) Method

CreateCatalog() private method

private CreateCatalog ( string folderInAppData, List pluginsToIgnore = null ) : System.ComponentModel.Composition.Hosting.AggregateCatalog
folderInAppData string
pluginsToIgnore List
return System.ComponentModel.Composition.Hosting.AggregateCatalog
        private AggregateCatalog CreateCatalog(string folderInAppData, List<string> pluginsToIgnore = null)
        {

            mExternalAssemblies.Clear();
            LoadReferenceLists();

            var returnValue = new AggregateCatalog();

            var pluginDirectories = GetPluginDirectories(folderInAppData);

            foreach (
                var directory in pluginDirectories)
            {
                AddPluginsFromDirectory(pluginsToIgnore, returnValue, directory);
            }

            if (mGlobal)
            {
                Assembly executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
                var newCatalog = new AssemblyCatalog(executingAssembly);
                returnValue.Catalogs.Add(newCatalog);



                Assembly entryAssembly = System.Reflection.Assembly.GetEntryAssembly();
                if (entryAssembly != executingAssembly && entryAssembly != null)
                {
                    newCatalog = new AssemblyCatalog(entryAssembly);
                    returnValue.Catalogs.Add(newCatalog);


                }

                foreach (var assembly in AddGlobalOnInitialize)
                {
                    newCatalog = new AssemblyCatalog(assembly);

                    returnValue.Catalogs.Add(newCatalog);

                }
            }

            return returnValue;
        }

Usage Example

Exemplo n.º 1
0
        protected static bool PopulateCatalog(PluginManagerBase instance, string pluginFolderInAppData, List <string> pluginsToIgnore = null)
        {
            instance.mError = false;

            ResolveEventHandler reh = new ResolveEventHandler(instance.currentDomain_AssemblyResolve);
            bool succeeded          = true;

            try
            {
                AppDomain currentDomain = AppDomain.CurrentDomain;
                //currentDomain.AssemblyResolve += reh;

                AggregateCatalog catalog = instance.CreateCatalog(pluginFolderInAppData, pluginsToIgnore);

                // Before we compose the parts, we want to pull out any .dll that doesn't have its references satisfied
                // Update : this isn't going to work because sometimes a .dll references another .dll, but the other .dll
                // isn't used.
                //CleanUnreferencedDlls(catalog, instance);

                var container = new CompositionContainer(catalog);



                container.ComposeParts(instance);

                succeeded = true;
            }
            catch (Exception e)
            {
                // If we get here then output won't even print out or even load.
                // This invalidates all plugins, so we should show ane rror.
                MessageBox.Show("Error in a plugin that shut down the plugin system: \n\n" + e.ToString());


                instance.CompileErrors.Add("Error trying to load plugins: \r\n\r\n" + e.ToString());

                instance.InstantiateAllListsAsEmpty();

                succeeded = false;
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= reh;
            }
            return(succeeded);
        }
All Usage Examples Of FlatRedBall.Glue.Plugins.PluginManagerBase::CreateCatalog