コード例 #1
0
        public Plugin InstallPlugin(PluginInstallInput pluginInstallInput, bool?overrideEnabled)
        {
            PluginContainer pluginContainer = null;

            if (!string.IsNullOrEmpty(pluginInstallInput.VirtualPath))
            {
                pluginContainer = pluginEngine.GetPlugins(p => (p.Tag == null || !(p.Tag is Plugin)) && p.CompilationAssembly != null && string.Compare(p.VirtualPath, pluginInstallInput.VirtualPath, true) == 0).FirstOrDefault();
            }

            if (pluginContainer == null)
            {
                throw new InvalidOperationException("Could not find plugin to install");
            }

            ValidationStateDictionary validationState = ValidatePlugin(pluginContainer);
            Plugin plugin = repository.Save(new Plugin(context.Site.ID, pluginInstallInput.VirtualPath, validationState.IsValid && overrideEnabled.HasValue ? overrideEnabled.Value : validationState.IsValid, pluginContainer.GetPropertiesUsingDefaultValues()));

            plugin.Container        = pluginContainer;
            pluginContainer.Tag     = plugin;
            pluginContainer.IsValid = validationState.IsValid;

            pluginTemplateRegistry.Reload(pluginEngine);
            context.Routes.Reload(modules, this, pluginEngine);
            pluginStyleRegistry.Reload(pluginEngine);
            pluginScriptRegistry.Reload(pluginEngine);

            return(plugin);
        }
コード例 #2
0
        public static PluginContainer GetPlugin(this IPluginEngine pluginEngine, Plugin plugin)
        {
            PluginContainer pluginContainer = null;

            if (plugin.ID != Guid.Empty || !string.IsNullOrEmpty(plugin.VirtualPath))
            {
                pluginContainer = pluginEngine.GetPlugins(p => (p.Tag != null && p.Tag is Plugin && ((Plugin)p.Tag).ID == plugin.ID) || string.Compare(p.VirtualPath, plugin.VirtualPath, true) == 0).FirstOrDefault();
            }

            return(pluginContainer);
        }
コード例 #3
0
 public static IEnumerable <PluginContainer> GetInstalledAndEnabledPlugins(this IPluginEngine pluginEngine)
 {
     return(pluginEngine.GetPlugins(getInstalledAndEnabled(pluginEngine)));
 }
コード例 #4
0
 public OxiteViewModelItems <PluginContainer> List(bool?installed)
 {
     return(new OxiteViewModelItems <PluginContainer>(installed != null ? pluginEngine.GetPlugins(p => (bool)installed ? p.Tag is Plugin : p.Tag == null || !(p.Tag is Plugin)).FillContainer(pluginEngine) : pluginEngine.GetPlugins().FillContainer(pluginEngine)));
 }