public static void Start() {
            var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) {
                UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
            };

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);

            // regist bundles
            var jsList = new string[] { 
                "Code.js",
                "Config.js",
                "Generator.js",
                "Menu.js",
                "Organize.js",
                "Parameter.js",
                "Permission.js",
                "Role.js",
                "User.js"
            };

            foreach (var js in jsList)
                BundleTable.Bundles.Add(new ScriptBundle("~/Resource/Sys/" + js).Include("~/Resource/Zephyr.Web.Sys/Areas/Sys/ViewModels/" + js));

            App.GetDefaultConnectionName = DbCreatorBase.GetDefaultConnectionName;
            if (AppSettings.Entrance.GetType() == typeof(DefaultWebEntrance))
                AppSettings.Entrance = new SysEntrance();
        }
예제 #2
0
		/// <summary>
		/// Create the view engine.
		/// </summary>
		public static void Init() {
			if (!Config.DisableManager) {
				// Create new precompiled view engine
				var engine = new PrecompiledMvcEngine(typeof(ManagerModule).Assembly) {
					UsePhysicalViewsIfNewer = true
				} ;
				engine.PartialViewLocationFormats = engine.PartialViewLocationFormats.Union(ExtensionsFolder).ToArray();
				var standard = new RazorViewEngine() ;
				standard.PartialViewLocationFormats = standard.PartialViewLocationFormats.Union(ExtensionsFolder).ToArray() ;

				ViewEngines.Engines.Insert(0, standard) ;
				ViewEngines.Engines.Insert(1, engine) ;

				VirtualPathFactoryManager.RegisterVirtualPathFactory(engine) ;

				// Register the manager area
				var manager = new ManagerRegistration() ;
				var context = new AreaRegistrationContext(manager.AreaName, RouteTable.Routes) ;
				manager.RegisterArea(context) ;

				// Register custom model binders
				RegisterBinders() ;

				// Register json deserialization for post data
				ValueProviderFactories.Factories.Add(new JsonValueProviderFactory());

				// Register application part
				ApplicationPart.Register(new ApplicationPart(typeof(ManagerModule).Assembly, "~/")) ;
			}
		}
예제 #3
0
파일: Mvc.cs 프로젝트: chandru9279/zasz.me
        /* Eliminated all vbhtml and aspx, and unused locations, and engines*/
        private static void SetupRazor()
        {
            ViewEngines.Engines.Clear();

            var razor = new PrecompiledMvcEngine(typeof(Mvc).Assembly)
                            {
                                UsePhysicalViewsIfNewer = true
                            };

            ViewEngines.Engines.Insert(0, razor);

            // StartPage lookups are done by WebPages.
            VirtualPathFactoryManager.RegisterVirtualPathFactory(razor);

            // Not using areas, not using vbhtmls.
            var areaViewLocations = new string[0];
            var viewLocations = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" };
            razor.AreaMasterLocationFormats = areaViewLocations;
            razor.AreaPartialViewLocationFormats = areaViewLocations;
            razor.AreaViewLocationFormats = areaViewLocations;
            razor.MasterLocationFormats = viewLocations;
            razor.PartialViewLocationFormats = viewLocations;
            razor.ViewLocationFormats = viewLocations;
            ViewEngines.Engines.Add(razor);
        }
예제 #4
0
        public static void MvcEngine(Assembly asm, bool allowTest = false)
        {
            if (isInitialized || allowTest) // (HttpContext.Current == null && !allowTest))
            {
                return;
            }

            isTest = HttpContext.Current == null;
#if MVCHOST
            var engine = new PrecompiledMvcEngine(asm)
            {
                UsePhysicalViewsIfNewer = false, // HttpContext.Current.Request.IsLocal
                PreemptPhysicalFiles    = true
            };
#else
            var engine = new PrecompiledMvcEngine(asm)
            {
                UsePhysicalViewsIfNewer = false, // HttpContext.Current.Request.IsLocal
                PreemptPhysicalFiles    = false
            };
#endif

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages.
            System.Web.WebPages.VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            isInitialized = true;
        }
        public object CreateInstance(string virtualPath)
        {
            virtualPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(virtualPath);

            ViewMapping mapping;

            if (!_mappings.TryGetValue(virtualPath, out mapping))
            {
                return(null);
            }

            if (!mapping.ViewAssembly.PreemptPhysicalFiles && VirtualPathProvider.FileExists(virtualPath))
            {
                // If we aren't pre-empting physical files, use the BuildManager to create _ViewStart instances if the file exists on disk.
                return(BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(WebPageRenderingBase)));
            }

            if (mapping.ViewAssembly.UsePhysicalViewsIfNewer && mapping.ViewAssembly.IsPhysicalFileNewer(virtualPath))
            {
                // If the physical file on disk is newer and the user's opted in this behavior, serve it instead.
                return(BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(WebViewPage)));
            }

            return(_viewPageActivator.Create((ControllerContext)null, mapping.Type));
        }
        public static void Start()
        {
            object engine = null;
            try
            {
                engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly)
                {
                    UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
                };
            }
            catch (System.Reflection.ReflectionTypeLoadException e)
            {
                string exceptions = "The following DLL load exceptions occurred:";
                foreach (var x in e.LoaderExceptions)
                {
                    exceptions += x.Message + ",\n\n";
                }
                throw new Exception("Error loading Razor Generator Stuff:\n" + exceptions);
            }

            ViewEngines.Engines.Insert(0, engine as PrecompiledMvcEngine);

            // StartPage lookups are done by WebPages.
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine as PrecompiledMvcEngine);
        }
        public static void Start() {
            var engine = new PrecompiledMvcEngine(typeof(PrecompiledMvcViewEngineStart).Assembly);

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
        }
        public static void Start() {
            var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) {
                UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
            };

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(engine);
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
        }
예제 #9
0
        public static void RegisterViewEngines(ViewEngineCollection viewEngines)
        {
            var engine = new PrecompiledMvcEngine(typeof(ViewEngineConfig).Assembly)
            {
                UsePhysicalViewsIfNewer = MvcApplication.DebugEnvironment
            };

            viewEngines.Insert(0, engine);
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
        }
예제 #10
0
        public static void Start() {
            var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) {
                UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
            };

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
        }
        public PrecompiledViewAssembly(Assembly assembly, string baseVirtualPath)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            _baseVirtualPath       = PrecompiledMvcEngine.NormalizeBaseVirtualPath(baseVirtualPath);
            _assembly              = assembly;
            _assemblyLastWriteTime = new Lazy <DateTime>(() => _assembly.GetLastWriteTimeUtc(fallback: DateTime.MaxValue));
        }
        public static void Start()
        {
            if (_startMethodExecuted == true)
            {
                return;
            }

            var engine = new PrecompiledMvcEngine(typeof(MvcSample.PreApplicationStartCode).Assembly);

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);

            _startMethodExecuted = true;
        }
예제 #13
0
		/// <summary>
		/// Initializes the application.
		/// </summary>
		public static void Init() { 
			// Register precompiled views
			var assemblies = new List<Assembly>();

			// Check if any modules have registered for precompiled views.
			if (Hooks.RegisterPrecompiledViews != null)
				Hooks.RegisterPrecompiledViews(assemblies);

			// Create precompiled view engines for all requested modules.
			foreach (var assembly in assemblies) { 
				var engine = new PrecompiledMvcEngine(assembly) {
					UsePhysicalViewsIfNewer = true
				};
				ViewEngines.Engines.Add(engine);
				VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
			}
		}
        protected override bool FileExists(ControllerContext controllerContext, string virtualPath)
        {
            virtualPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(virtualPath);

            ViewMapping mapping;

            if (!_mappings.TryGetValue(virtualPath, out mapping))
            {
                return(false);
            }

            if (mapping.ViewAssembly.UsePhysicalViewsIfNewer && mapping.ViewAssembly.IsPhysicalFileNewer(virtualPath))
            {
                // If the physical file on disk is newer and the user's opted in this behavior, serve it instead.
                return(false);
            }
            return(Exists(virtualPath));
        }
        private static void RegisterRazorGeneratedViewEngine()
        {
            var mainEngine = new PrecompiledMvcEngine(typeof(PizzaMvcPostApplicationStart).Assembly)
            {
                UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal,
            };

            ViewEngines.Engines.Insert(0, mainEngine);
            VirtualPathFactoryManager.RegisterVirtualPathFactory(mainEngine);

            var areaNames = RouteTableHelper.GetApplicationAreaNames();
            foreach (var areaName in areaNames)
            {
                var engine = new PrecompiledMvcEngine(typeof(PizzaMvcPostApplicationStart).Assembly, string.Format("~/Areas/{0}/", areaName))
                {
                    UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal,
                };

                ViewEngines.Engines.Insert(0, engine);
                VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            }
        }
예제 #16
0
		/// <summary>
		/// Registers the goldfish view engine.
		/// </summary>
		public static void Register() {
			// Clear the view enginges collection
			ViewEngines.Engines.Clear();

			// Create the theme view engines
			ViewEngines.Engines.Add(new ViewEngine());

			var assemblies = new List<Assembly>();

			// Check if any modules have registered for precompiled views.
			if (Hooks.App.Init.RegisterPrecompiledViews != null)
				Hooks.App.Init.RegisterPrecompiledViews(assemblies);

			// Create precompiled view engines for all requested modules.
			foreach (var assembly in assemblies) { 
				var engine = new PrecompiledMvcEngine(assembly) {
					UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
				};
				ViewEngines.Engines.Add(engine);
				VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
			}
		}
예제 #17
0
파일: Startup.cs 프로젝트: d-popov/Piranha
		private static void RegisterViewEngines() { 
			// Register the standard view engine
			var standard = new RazorViewEngine() ;
			standard.PartialViewLocationFormats = standard.PartialViewLocationFormats.Union(partialViewFolders).ToArray() ;
			ViewEngines.Engines.Add(standard) ;

			// Get precompiled view assemblies
			var assemblies = new List<Assembly>();

			if (Hooks.App.Init.RegisterPrecompiledViews != null)
				Hooks.App.Init.RegisterPrecompiledViews(assemblies);
			assemblies.Insert(0, typeof(Startup).Assembly);

			foreach (var assembly in assemblies) { 
				var engine = new PrecompiledMvcEngine(assembly) {
					UsePhysicalViewsIfNewer = true
				} ;
				engine.PartialViewLocationFormats = engine.PartialViewLocationFormats.Union(partialViewFolders).ToArray();

				ViewEngines.Engines.Add(engine);
				VirtualPathFactoryManager.RegisterVirtualPathFactory(engine) ;
			}
		}
        public static void Start()
        {
            if (_startMethodExecuted == true)
            {
                return;
            }

            var engine = new PrecompiledMvcEngine(typeof(PreApplicationStartCode).Assembly);

            // If you have multiple assemblies with precompiled views,
            // use CompositePrecompiledMvcEngine:
            //
            //var engine = new CompositePrecompiledMvcEngine(
            //    PrecompiledViewAssembly.OfType<YourType>(),
            //    PrecompiledViewAssembly.OfType<PreApplicationStartCode>(
            //        usePhysicalViewsIfNewer: HttpContext.Current.IsDebuggingEnabled));

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);

            _startMethodExecuted = true;
        }
예제 #19
0
        public virtual void PreStart()
        {
            lock (PluginLoader.ViewEnginesList)
            {
                lock (ViewEngines.Engines)
                {

                    if (!PluginLoader.ViewEnginesList.ContainsKey(PluginName))
                    {
                        var engine = new PrecompiledMvcEngine(this, PluginLoader.PluginPath + PluginName);
                        ViewEngines.Engines.Insert(0, engine);
                        VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
                        PluginLoader.ViewEnginesList.Add(PluginName, engine);
                    }
                    else
                    {
                        foreach (var item in ViewEngines.Engines)
                        {
                            if (item is PrecompiledMvcEngine)
                            {
                                var eg = item as PrecompiledMvcEngine;
                                if (eg.PluginContext.PluginName == PluginName)
                                {
                                    eg.RePrecomplies(this);
                                    foreach (var viewType in eg._mappings.Keys)
                                    {
                                        BuildManager.GetCompiledType(viewType);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #20
0
        public static void MvcEngine(Assembly asm, bool allowTest = false)
        {
            if (isInitialized || allowTest) // (HttpContext.Current == null && !allowTest))
                return;

            isTest = HttpContext.Current == null;
            #if MVCHOST
            var engine = new PrecompiledMvcEngine(asm)
            {
                UsePhysicalViewsIfNewer = false, // HttpContext.Current.Request.IsLocal
                PreemptPhysicalFiles = true
            };
            #else
            var engine = new PrecompiledMvcEngine(asm)
            {
                UsePhysicalViewsIfNewer = false, // HttpContext.Current.Request.IsLocal
                PreemptPhysicalFiles = false
            };

            #endif

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages.
            System.Web.WebPages.VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            isInitialized = true;
        }
 public bool IsPhysicalFileNewer(string virtualPath)
 {
     return(PrecompiledMvcEngine.IsPhysicalFileNewer(virtualPath, _baseVirtualPath, _assemblyLastWriteTime));
 }
        public bool Exists(string virtualPath)
        {
            virtualPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(virtualPath);

            return(_mappings.ContainsKey(virtualPath));
        }
        protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath)
        {
            partialPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(partialPath);

            return(CreateViewInternal(partialPath, masterPath: null, runViewStartPages: false));
        }
        protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
        {
            viewPath = PrecompiledMvcEngine.EnsureVirtualPathPrefix(viewPath);

            return(CreateViewInternal(viewPath, masterPath, runViewStartPages: true));
        }