public void SetUp()
 {
     RazorFormat = new RazorFormat {
         DefaultBaseType = typeof(CustomRazorBasePage<>),
         VirtualPathProvider = new InMemoryVirtualPathProvider(new BasicAppHost()),
         TemplateProvider = { CompileInParallelWithNoOfThreads = 0 },
     };
     RazorFormat.Init();            
 }
		public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents, RazorPageType pageType)
			: this()
		{
			RazorFormat = razorFormat;
			FilePath = fullPath;
			Name = name;
			Contents = contents;
			PageType = pageType;
		}
        public void Register(IAppHost appHost)
        {
            if (Instance != null)
            {
                Log.Warn("RazorFormat plugin should only be registered once");
                return;
            }

            Instance = this;

            this.AppHost = appHost;
            this.ViewManager = new ViewManager(appHost, this.ViewConfig);
            this.BuildManager = new BuildManager(appHost, this.BuildConfig);
            this.PageResolver = new PageResolver(appHost, this.ResolveConfig, this.ViewManager, this.BuildManager);
        }
        public override void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName)
        {
            httpRes.ContentType = ContentType.Html;
            if (RazorFormat == null)
            {
                RazorFormat = RazorFormat.Instance;
            }

            var contentPage = RazorPage ?? RazorFormat.FindByPathInfo(PathInfo);

            if (contentPage == null)
            {
                httpRes.StatusCode = (int)HttpStatusCode.NotFound;
                httpRes.EndHttpRequest();
                return;
            }

            if (RazorFormat.WatchForModifiedPages)
            {
                RazorFormat.ReloadIfNeeeded(contentPage);
            }

            //Add good caching support
            //if (httpReq.DidReturn304NotModified(contentPage.GetLastModified(), httpRes))
            //    return;

            var model = Model;

            if (model == null)
            {
                httpReq.Items.TryGetValue("Model", out model);
            }
            if (model == null)
            {
                var modelType = RazorPage != null?RazorPage.GetRazorTemplate().ModelType : null;

                model = modelType == null || modelType == typeof(DynamicRequestObject)
                    ? null
                    : DeserializeHttpRequest(modelType, httpReq, httpReq.ContentType);
            }

            RazorFormat.ProcessRazorPage(httpReq, contentPage, model, httpRes);
        }
 public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents)
     : this(razorFormat, fullPath, name, contents, RazorPageType.ViewPage)
 {
 }
		public void TestFixtureSetUp()
		{
			mvcRazorFormat = new RazorFormat { DefaultBaseType = typeof(CustomRazorBasePage<>) };
			mvcRazorFormat.Init();
		}
Exemple #7
0
 public ErrorViewPage(RazorFormat razorFormat, Exception ex)
     : base(razorFormat, null, DefaultPageName, ErrorPage(ex, DefaultContents))
 {
     this.ex = ex;
 }
		public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents)
			: this(razorFormat, fullPath, name, contents, RazorPageType.ViewPage) {}
 public ErrorViewPage(RazorFormat razorFormat, Exception ex)
     : base(razorFormat, null, DefaultPageName, ErrorPage(ex, DefaultContents))
 {
     this.ex = ex;
 }