コード例 #1
0
        public ActionResult EnablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
        {
            var plugin = _pluginManager.GetPlugin(pluginId, version);
            if (plugin == null)
            {
                return NotFound();
            }

            _pluginManager.EnablePlugin(plugin);
            return NoContent();
        }
コード例 #2
0
        public IActionResult Enable(Guid id)
        {
            var module = _pluginManager.GetPlugin(id);

            if (!PluginsLoadContexts.Any(module.Name))
            {
                var context = new CollectibleAssemblyLoadContext();

                _pluginManager.EnablePlugin(id);
                var moduleName = module.Name;

                var filePath = $"{AppDomain.CurrentDomain.BaseDirectory}Modules\\{moduleName}\\{moduleName}.dll";
                using (var fs = new FileStream(filePath, FileMode.Open))
                {
                    var assembly = context.LoadFromStream(fs);

                    var controllerAssemblyPart = new MyAssemblyPart(assembly);

                    AdditionalReferencePathHolder.AdditionalReferencePaths.Add(filePath);
                    _partManager.ApplicationParts.Add(controllerAssemblyPart);
                }

                MyActionDescriptorChangeProvider.Instance.HasChanged = true;
                MyActionDescriptorChangeProvider.Instance.TokenSource.Cancel();

                PluginsLoadContexts.AddPluginContext(module.Name, context);
            }
            else
            {
                var context = PluginsLoadContexts.GetContext(module.Name);
                var controllerAssemblyPart = new AssemblyPart(context.Assemblies.First());
                _partManager.ApplicationParts.Add(controllerAssemblyPart);
                _pluginManager.EnablePlugin(id);

                MyActionDescriptorChangeProvider.Instance.HasChanged = true;
                MyActionDescriptorChangeProvider.Instance.TokenSource.Cancel();
            }

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public IActionResult Enable(Guid id)
        {
            var module = _pluginManager.GetPlugin(id);

            _pluginManager.EnablePlugin(id);
            var moduleName = module.Name;

            var assembly = Assembly.LoadFile($"{AppDomain.CurrentDomain.BaseDirectory}Modules\\{moduleName}\\{moduleName}.dll");

            var controllerAssemblyPart = new AssemblyPart(assembly);

            _partManager.ApplicationParts.Add(controllerAssemblyPart);

            MyActionDescriptorChangeProvider.Instance.HasChanged = true;
            MyActionDescriptorChangeProvider.Instance.TokenSource.Cancel();

            return(RedirectToAction("Index"));
        }
コード例 #4
0
ファイル: PluginsController.cs プロジェクト: ym1100/CoolCat
 public IActionResult Enable(Guid id)
 {
     _pluginManager.EnablePlugin(id);
     return(RedirectToAction("Index"));
 }