/// <summary> /// Ctor. /// </summary>) /// <param name="sPluginAssemblyName">Raw name of the plugin assembly.</param> /// <param name="funcLoadAssembly">A funtion to load the assembly on-demand.</param> /// <param name="disabledplugins">A cached <see cref="PluginLoader.DisabledPlugins"/> instance for getting the initial <see cref="OmeaPluginsPageListEntry.IsEnabled"/> value.</param> /// <param name="pluginfileinfo">Info about the file the plugin were loaded from.</param> /// <param name="sRuntimeLoadError">If the plugin failed to be loaded at runtime, records the load error.</param> public OmeaPluginsPageListEntryPlugin([NotNull] string sPluginAssemblyName, [NotNull] Func <Assembly> funcLoadAssembly, PluginLoader.PossiblyPluginFileInfo pluginfileinfo, [NotNull] string sRuntimeLoadError, [NotNull] PluginLoader.DisabledPlugins disabledplugins) { if (sPluginAssemblyName == null) { throw new ArgumentNullException("sPluginAssemblyName"); } if (funcLoadAssembly == null) { throw new ArgumentNullException("funcLoadAssembly"); } if (disabledplugins == null) { throw new ArgumentNullException("disabledplugins"); } if (sRuntimeLoadError == null) { throw new ArgumentNullException("sRuntimeLoadError"); } _funcLoadAssembly = funcLoadAssembly; _pluginfileinfo = pluginfileinfo; _sRuntimeLoadError = sRuntimeLoadError; _assemblyinfo = OmeaPluginsPageAssemblyInfo.CreateNotLoaded(sPluginAssemblyName, _pluginfileinfo, _sRuntimeLoadError); _bIsEnabledInitially = !disabledplugins.Contains(sPluginAssemblyName); IsEnabled = _bIsEnabledInitially; }
/// <summary> /// Not-loaded-mode ctor. /// </summary> /// <param name="sAssemblyName">The assembly name. Mandatory. For display needs only.</param> /// <param name="pluginfileinfo">Plugin file of origin.</param> /// <param name="sRuntimeLoadError">If the plugin failed to be loaded at runtime, records the load error.</param> private OmeaPluginsPageAssemblyInfo([NotNull] string sAssemblyName, PluginLoader.PossiblyPluginFileInfo pluginfileinfo, [NotNull] string sRuntimeLoadError) { if (sAssemblyName.IsEmpty()) { throw new ArgumentNullException("sAssemblyName"); } _sPluginAssemblyName = sAssemblyName; _pluginfileinfo = pluginfileinfo; _sRuntimeLoadError = sRuntimeLoadError; }
/// <summary> /// Loaded-mode ctor. /// </summary> /// <param name="assembly">The assembly, if loaded.</param> /// <param name="plugintypes">Preloaded plugin types to create the descriptions from.</param> /// <param name="pluginfileinfo">Plugin file origin information.</param> /// <param name="sRuntimeLoadError">If the plugin failed to be loaded at runtime, records the load error.</param> private OmeaPluginsPageAssemblyInfo([NotNull] Assembly assembly, [NotNull] IList <Type> plugintypes, PluginLoader.PossiblyPluginFileInfo pluginfileinfo, [NotNull] string sRuntimeLoadError) : this(assembly.GetName().Name, pluginfileinfo, sRuntimeLoadError) { // Called non-loaded base ctor _isLoaded = true; // Assembly _assembly = assembly; // Is Primary? try { var fiAssembly = new FileInfo(new Uri(assembly.CodeBase).LocalPath); string sError; _isPrimary = (_pluginfileinfo.Folder.IsPrimary) && (PluginLoader.IsPrimaryAssemblyStrongNameOk(assembly.GetName(), fiAssembly.FullName, out sError)); _plugins = LoadPluginsList(plugintypes); } catch (Exception ex) { Core.ReportBackgroundException(ex); } }
public static OmeaPluginsPageAssemblyInfo CreateNotLoaded([NotNull] string sAssemblyName, PluginLoader.PossiblyPluginFileInfo pluginfileinfo, [NotNull] string sRuntimeLoadError) { return(new OmeaPluginsPageAssemblyInfo(sAssemblyName, pluginfileinfo, sRuntimeLoadError)); }
public static OmeaPluginsPageAssemblyInfo CreateFromAssembly([NotNull] Assembly assembly, [NotNull] IList <Type> plugintypes, PluginLoader.PossiblyPluginFileInfo pluginfileinfo, [NotNull] string sRuntimeLoadError) { return(new OmeaPluginsPageAssemblyInfo(assembly, plugintypes, pluginfileinfo, sRuntimeLoadError)); }
public OmeaPluginsPageListEntryNonPlugin(PluginLoader.PossiblyPluginFileInfo info) { _file = info; }
/// <summary> /// Harvest the plugins, both loaded and not. /// </summary> private void FillPluginsList() { _arItems.Clear(); _queueItemsToLoad.Clear(); var disabledplugins = new PluginLoader.DisabledPlugins(); var hashDisoveredPluginAssemblies = new HashSet <string>(); var pluginloader = (PluginLoader)Core.PluginLoader; // Stage 1: loaded plugins foreach (IPlugin plugin in pluginloader.GetLoadedPlugins()) { try { string asmname = plugin.GetType().Assembly.GetName().Name; if (!hashDisoveredPluginAssemblies.Add(asmname)) { continue; } // Submit IPlugin pluginConst = plugin; PluginLoader.PossiblyPluginFileInfo pluginfile = pluginloader.GetPluginFileInfo(plugin); _arItems.Add(new OmeaPluginsPageListEntryPlugin(asmname, () => pluginConst.GetType().Assembly, pluginfile, pluginloader.GetPluginLoadRuntimeError(pluginfile.File), disabledplugins)); } catch (Exception ex) { Core.ReportBackgroundException(ex); } } // Stage 2: not loaded plugins (and non-plugins in Debug mode) foreach (PluginLoader.PossiblyPluginFileInfo file in pluginloader.GetAllPluginFiles()) { try { if (file.IsPlugin) { string asmname = Path.GetFileNameWithoutExtension(file.File.FullName); if (!hashDisoveredPluginAssemblies.Add(asmname)) { continue; } // Submit FileInfo fileConst = file.File; _arItems.Add(new OmeaPluginsPageListEntryPlugin(asmname, () => PluginLoader.LoadPluginAssembly(fileConst), file, pluginloader.GetPluginLoadRuntimeError(file.File), disabledplugins)); } else if (ShowDebugInfo) { _arItems.Add(new OmeaPluginsPageListEntryNonPlugin(file)); } } catch (Exception ex) { Core.ReportBackgroundException(ex); } } // Create the view for this collection that supports sorting, grouping and sharing the selection if (_arItemsView == null) // Reuse afterwards, as it takes part in databinding { _arItemsView = CollectionViewSource.GetDefaultView(_arItems); _arItemsView.SortDescriptions.Add(new SortDescription("IsEnabledInitially", ListSortDirection.Descending)); _arItemsView.SortDescriptions.Add(new SortDescription("Title", ListSortDirection.Ascending)); _arItemsView.GroupDescriptions.Add(new PropertyGroupDescription("IsEnabledInitially", ValueConverter.Create((bool b) => b ? Stringtable.Enabled : Stringtable.Disabled))); } else { _arItemsView.Refresh(); } // Shedulle loading of the items foreach (OmeaPluginsPageListEntry item in _arItems) { if (item is OmeaPluginsPageListEntryPlugin) { _queueItemsToLoad.Enqueue((OmeaPluginsPageListEntryPlugin)item); } } if (_queueItemsToLoad.Count > 0) { Core.UserInterfaceAP.QueueJob(Stringtable.JobLoadPluginAssemblies, PumpLoadQueue); } }