/// <summary>
     /// Initialize plugin manager and register all plugins
     /// </summary>
 	public static void Initialize()
     {
         IList<PrecompiledViewAssembly> assemblies = new List<PrecompiledViewAssembly>();
         foreach (var asmbl in PluginManager.Current.Modules.Values)
         {
             assemblies.Add(new PrecompiledViewAssembly(asmbl));
         }
         var engine = new CompositePrecompiledMvcEngine(assemblies.ToArray());
         ViewEngines.Engines.Insert(0, engine);
         VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
     }
        /// <summary>
        /// Loads available assemblies.
        /// </summary>
        public static void LoadAssemblies()
        {
            ApplicationContext.LoadAssemblies();

            using (var container = ContextScopeProvider.CreateChildContainer())
            {
                if (HostingEnvironment.IsHosted)
                {
                    HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourcesVirtualPathProvider(container.Resolve<IEmbeddedResourcesProvider>()));
                }
                else
                {
                    if (!IsTestMode)
                    {
                        throw new CoreException("Failed to register EmbeddedResourcesVirtualPathProvider as a virtual path provider.");
                    }
                }

                ControllerBuilder.Current.SetControllerFactory(container.Resolve<DefaultWebControllerFactory>());

                // Register precompiled views for all the assemblies
                var precompiledAssemblies = new List<PrecompiledViewAssembly>();

                var moduleRegistration = container.Resolve<IModulesRegistration>();
                moduleRegistration.GetModules().Select(m => m.ModuleDescriptor).Distinct().ToList().ForEach(
                    descriptor =>
                    {
                        var webDescriptor = descriptor as WebModuleDescriptor;
                        if (webDescriptor != null)
                        {
                            var precompiledAssembly = new PrecompiledViewAssembly(descriptor.GetType().Assembly, string.Format("~/Areas/{0}/", webDescriptor.AreaName))
                            {
                                UsePhysicalViewsIfNewer = false
                            };
                            precompiledAssemblies.Add(precompiledAssembly);
                        }
                    });

                var engine = new CompositePrecompiledMvcEngine(precompiledAssemblies.ToArray());
                ViewEngines.Engines.Insert(0, engine);
                VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            }
        }
Esempio n. 3
0
 public void Execute()
 {
     var engine = new CompositePrecompiledMvcEngine(PrecompiledViewAssembly.OfType<AddViewEngine>());
     ViewEngines.Engines.Add(engine);
     VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
 }
Esempio n. 4
0
        /// <summary>
        /// Loads available assemblies.
        /// </summary>
        internal static void LoadAssemblies()
        {
            using (var container = ContextScopeProvider.CreateChildContainer())
            {
                if (container == null)
                {
                    throw new CmsException("Better CMS dependencies container is not initialized.");
                }

                if (HostingEnvironment.IsHosted)
                {
                    HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourcesVirtualPathProvider(container.Resolve<IEmbeddedResourcesProvider>()));
                }
                else
                {
                    throw new CmsException("Failed to register EmbeddedResourcesVirtualPathProvider as a virtual path provider.");
                }

                ControllerBuilder.Current.SetControllerFactory(container.Resolve<DefaultCmsControllerFactory>());

                IAssemblyManager assemblyManager = container.Resolve<IAssemblyManager>();
                                
                // First add referenced modules...
                assemblyManager.AddReferencedModules();
                
                // ...then scan and register uploaded modules.
                assemblyManager.AddUploadedModules();

                var moduleRegistration = container.Resolve<IModulesRegistration>();
                moduleRegistration.InitializeModules();

                // Register precompiled views for all the assemblies
                var precompiledAssemblies = new List<PrecompiledViewAssembly>();
                moduleRegistration.GetModules().Select(m => m.ModuleDescriptor).Distinct().ForEach(
                    descriptor =>
                        {
                            var precompiledAssembly = new PrecompiledViewAssembly(descriptor.GetType().Assembly, string.Format("~/Areas/{0}/", descriptor.AreaName))
                                                  {
                                                      UsePhysicalViewsIfNewer = false
                                                  };
                            precompiledAssemblies.Add(precompiledAssembly);
                        });
                
                var engine = new CompositePrecompiledMvcEngine(precompiledAssemblies.ToArray());
                ViewEngines.Engines.Add(engine);
                VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            }
        }