Ejemplo n.º 1
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>()));
                }

                ControllerBuilder.Current.SetControllerFactory(container.Resolve <DefaultCmsControllerFactory>());
                ViewEngines.Engines.Insert(0, new EmbeddedResourcesViewEngine());

                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();
            }
        }
Ejemplo n.º 2
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.Insert(0, engine);
                VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads available assemblies.
        /// </summary>
        public static void LoadAssemblies()
        {
            using (var container = ContextScopeProvider.CreateChildContainer())
            {
                if (container == null)
                {
                    throw new CoreException("Application dependencies container is not initialized.");
                }

                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();
            }
        }