コード例 #1
0
        private void InitWebpage()
        {
            if (string.IsNullOrEmpty(RazorScriptFile))
            {
                return;
            }
            var objectValue = RuntimeHelpers.GetObjectValue(CreateWebPageInstance());

            if (objectValue == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "The webpage found at '{0}' was not created.", RazorScriptFile));
            }

            Webpage = objectValue as RazorWebPage;

            if (Webpage == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "The webpage at '{0}' must derive from RazorEnabledPage.", RazorScriptFile));
            }
            Webpage.Context     = HttpContext;
            Webpage.VirtualPath = VirtualPathUtility.GetDirectory(RazorScriptFile);
            InitHelpers(Webpage);
        }
コード例 #2
0
 private void InitHelpers(RazorWebPage webPage)
 {
     webPage.Html = new HtmlHelper(webPage.Context);
     webPage.Url  = new UrlHelper(webPage.Context);
 }