public void SetUp()
 {
     RazorFormat = new RazorFormat {
         DefaultBaseType = typeof(CustomRazorBasePage<>),
         VirtualPathProvider = new InMemoryVirtualPathProvider(new BasicAppHost()),
         TemplateProvider = { CompileInParallelWithNoOfThreads = 0 },
     };
     RazorFormat.Init();            
 }
예제 #2
0
		public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents, RazorPageType pageType)
			: this()
		{
			RazorFormat = razorFormat;
			FilePath = fullPath;
			Name = name;
			Contents = contents;
			PageType = pageType;
		}
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
 public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents)
     : this(razorFormat, fullPath, name, contents, RazorPageType.ViewPage)
 {
 }
예제 #6
0
		public void TestFixtureSetUp()
		{
			mvcRazorFormat = new RazorFormat { DefaultBaseType = typeof(CustomRazorBasePage<>) };
			mvcRazorFormat.Init();
		}
예제 #7
0
 public ErrorViewPage(RazorFormat razorFormat, Exception ex)
     : base(razorFormat, null, DefaultPageName, ErrorPage(ex, DefaultContents))
 {
     this.ex = ex;
 }
예제 #8
0
		public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents)
			: this(razorFormat, fullPath, name, contents, RazorPageType.ViewPage) {}
예제 #9
0
 public ErrorViewPage(RazorFormat razorFormat, Exception ex)
     : base(razorFormat, null, DefaultPageName, ErrorPage(ex, DefaultContents))
 {
     this.ex = ex;
 }