public static PluginLoadOptionsBuilder <T> LocalOrNetwork <T>(this PluginLoadOptionsBuilder <T> optionsBuilder, bool network = false)
 {
     if (network)
     {
         return(optionsBuilder.WithNetworkAssemblyLoader <TenantPluginNetworkLoadOptions <T> >());
     }
     return(optionsBuilder.WithLocalDiskAssemblyLoader());
 }
 /// <summary>
 /// Does all of the plumbing to load API Controllers as Prise Plugins.
 /// Limitiations:
 /// - No DispatchProxy can be used, backwards compatability is compromised (DispatchProxy requires an interface as base class, not ControllerBase)
 /// - Plugin Cache is set to Singleton because we cannot unload assemblies, this would disable the controller routing (and result in 404)
 /// - Assembly unloading is disabled, memory leaks can occur
 /// </summary>
 /// <typeparam name="T">The Plugin Contract Type</typeparam>
 /// <param name="builder"></param>
 /// <returns>A fully configured Prise setup that will load Controllers from Plugin Assemblies</returns>
 public static PluginLoadOptionsBuilder <T> AddPriseControllersAsPlugins <T>(this PluginLoadOptionsBuilder <T> builder)
 {
     return(builder
            // Use a singleton cache
            .WithSingletonCache()
            .ConfigureServices(services =>
                               services
                               .ConfigureMVCServices <T>())
            // Makes sure controllers can be casted to the host's representation of ControllerBase
            .WithHostType(typeof(ControllerBase))
            );
 }
 /// <summary>
 /// Does all of the plumbing to load API Controllers and RAZOR Controllers as Prise Plugins.
 /// Limitiations:
 /// - No DispatchProxy can be used, backwards compatability is compromised (DispatchProxy requires an interface as base class, not ControllerBase)
 /// - Plugin Cache is set to Singleton because we cannot unload assemblies, this would disable the controller routing (and result in 404)
 /// - Assembly unloading is disabled, memory leaks can occur
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="builder"></param>
 /// <param name="webRootPath">By default, this should be the IWebHostEnvironment.WebRootPaht or IHostingEnvironment.WebRootPath</param>
 /// <returns></returns>
 public static PluginLoadOptionsBuilder <T> AddPriseRazorPlugins <T>(this PluginLoadOptionsBuilder <T> builder, string webRootPath)
 {
     return(builder
            // Use a singleton cache
            .WithSingletonCache()
            .ConfigureServices(services =>
                               services
                               .ConfigureMVCServices <T>()
                               .ConfigureRazorServices <T>(webRootPath))
            // Makes sure controllers can be casted to the host's representation of ControllerBase
            .WithHostType(typeof(ControllerBase))
            // Makes sure the Microsoft.AspNetCore.Mvc.ViewFeatures assembly is loaded from the host
            .WithHostType(typeof(ITempDataDictionaryFactory))
            );
 }
Example #4
0
        /// <summary>
        /// Does all of the plumbing to load API Controllers as Prise Plugins.
        /// Limitiations:
        /// - No DispatchProxy can be used, backwards compatability is compromised (DispatchProxy requires an interface as base class, not ControllerBase)
        /// - Plugin Cache is set to Singleton because we cannot unload assemblies, this would disable the controller routing (and result in 404)
        /// - Assembly unloading is disabled, memory leaks can occur
        /// </summary>
        /// <typeparam name="T">The Plugin Contract Type</typeparam>
        /// <param name="builder"></param>
        /// <returns>A fully configured Prise setup that will load Controllers from Plugin Assemblies</returns>
        public static PluginLoadOptionsBuilder <T> AddPriseControllersAsPlugins <T>(this PluginLoadOptionsBuilder <T> builder)
        {
            return(builder
                   // Use a singleton cache
                   .WithSingletonCache()
                   .ConfigureServices(services =>
                                      services
                                      .ConfigureMVCServices <T>())
#if NETCORE2_1
                   // This is required in 2.1 because there is no AssemblyDependencyResolver
                   .UsePluginContextAsDependencyPath()
#endif
                   // Makes sure controllers can be casted to the host's representation of ControllerBase
                   .WithHostType(typeof(ControllerBase))
                   );
        }
Example #5
0
        /// <summary>
        /// Does all of the plumbing to load API Controllers and RAZOR Controllers as Prise Plugins.
        /// Limitiations:
        /// - No DispatchProxy can be used, backwards compatability is compromised (DispatchProxy requires an interface as base class, not ControllerBase)
        /// - Plugin Cache is set to Singleton because we cannot unload assemblies, this would disable the controller routing (and result in 404)
        /// - Assembly unloading is disabled, memory leaks can occur
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="builder"></param>
        /// <param name="webRootPath">By default, this should be the IWebHostEnvironment.WebRootPaht or IHostingEnvironment.WebRootPath</param>
        /// <returns></returns>
        public static PluginLoadOptionsBuilder <T> AddPriseRazorPlugins <T>(this PluginLoadOptionsBuilder <T> builder, string webRootPath)
        {
            return(builder
                   // Use a singleton cache
                   .WithSingletonCache()
                   .ConfigureServices(services =>
                                      services
                                      .ConfigureMVCServices <T>()
                                      .ConfigureRazorServices <T>(webRootPath))
#if NETCORE2_1
                   // This is required in 2.1 because there is no AssemblyDependencyResolver
                   .UsePluginContextAsDependencyPath()
#endif
                   // Makes sure controllers can be casted to the host's representation of ControllerBase
                   .WithHostType(typeof(ControllerBase))
                   // Makes sure the Microsoft.AspNetCore.Mvc.ViewFeatures assembly is loaded from the host
                   .WithHostType(typeof(ITempDataDictionaryFactory))
                   );
        }