Exemplo n.º 1
0
        public async Task <IActionResult> TestLoadPlugin()
        {
            var path = Path.Combine(pluginManagers.GetBasePluginsPath(), "Brochure.Authority", "plugin.config");
            var p    = await pluginLoader.LoadPlugin(path);

            if (!(p is Plugins plugin))
            {
                return new ContentResult()
                       {
                           Content = "bbb"
                       }
            }
            ;

            var startConfigs = reflectorUtil.GetObjectOfBase <IStarupConfigure>(plugin.Assembly);

            //         var context = new PluginMiddleContext(app.ServiceProvider, plugin.Key);
            //  plugin.Context.Services.Add(context);
            foreach (var item in startConfigs)
            {
                item.Configure(plugin.Key, applicationBuilder);
            }
            mvcBuilder.AddApplicationPart(plugin.Assembly);

            PluginActionDescriptorChangeProvider.Instance.HasChanged = true;
            PluginActionDescriptorChangeProvider.Instance.TokenSource.Cancel();
            return(new ContentResult()
            {
                Content = "aaa"
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Loads the module.
 /// </summary>
 /// <param name="services">The services.</param>
 /// <param name="assembly">The assembly.</param>
 public void LoadModule(IServiceCollection services, Assembly assembly)
 {
     try
     {
         var modules = reflectorUtil.GetObjectOfBase <IModule>(assembly);
         if (!modules.Any())
         {
             return;
         }
         foreach (var item in modules)
         {
             item.ConfigModule(services);
         }
         foreach (var item in modules)
         {
             item.Initialization(AccessServiceProvider.Service ?? services.BuildServiceProvider());
         }
     }
     catch (System.Exception e)
     {
         logger.LogError(e, e.Message);
         throw;
     }
 }