public void SetUp()
 {
     RazorFormat = new RazorFormat {
         DefaultBaseType = typeof(CustomRazorBasePage<>),
         VirtualPathProvider = new InMemoryVirtualPathProvider(new BasicAppHost()),
         TemplateProvider = { CompileInParallelWithNoOfThreads = 0 },
     };
     RazorFormat.Init();            
 }
Exemplo n.º 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;
		}
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents)
     : this(razorFormat, fullPath, name, contents, RazorPageType.ViewPage)
 {
 }
Exemplo n.º 6
0
		public void TestFixtureSetUp()
		{
			mvcRazorFormat = new RazorFormat { DefaultBaseType = typeof(CustomRazorBasePage<>) };
			mvcRazorFormat.Init();
		}
Exemplo n.º 7
0
 public ErrorViewPage(RazorFormat razorFormat, Exception ex)
     : base(razorFormat, null, DefaultPageName, ErrorPage(ex, DefaultContents))
 {
     this.ex = ex;
 }
Exemplo n.º 8
0
		public ViewPageRef(RazorFormat razorFormat, string fullPath, string name, string contents)
			: this(razorFormat, fullPath, name, contents, RazorPageType.ViewPage) {}
Exemplo n.º 9
0
 public ErrorViewPage(RazorFormat razorFormat, Exception ex)
     : base(razorFormat, null, DefaultPageName, ErrorPage(ex, DefaultContents))
 {
     this.ex = ex;
 }