本文整理汇总了C#中ServiceStack.Razor.Managers.RazorPage.ActivateInstance方法的典型用法代码示例。如果您正苦于以下问题:C# RazorPage.ActivateInstance方法的具体用法?C# RazorPage.ActivateInstance怎么用?C# RazorPage.ActivateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.Razor.Managers.RazorPage
的用法示例。
在下文中一共展示了RazorPage.ActivateInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRazorPageInstance
private IRazorView CreateRazorPageInstance(IHttpRequest httpReq, IHttpResponse httpRes, object dto, RazorPage razorPage)
{
EnsureCompiled(razorPage, httpRes);
//don't proceed any further, the background compiler found there was a problem compiling the page, so throw instead
if (razorPage.CompileException != null)
{
throw razorPage.CompileException;
}
//else, EnsureCompiled() ensures we have a page type to work with so, create an instance of the page
var page = (IRazorView) razorPage.ActivateInstance();
page.Init(viewEngine: this, httpReq: httpReq, httpRes: httpRes);
//deserialize the model.
PrepareAndSetModel(page, httpReq, dto);
return page;
}
示例2: CreateRazorPageInstance
private IRazorView CreateRazorPageInstance(IRequest httpReq, IResponse httpRes, object dto, RazorPage razorPage)
{
viewManager.EnsureCompiled(razorPage);
//don't proceed any further, the background compiler found there was a problem compiling the page, so throw instead
if (razorPage.CompileException != null)
{
if (Text.Env.IsMono)
{
//Additional debug info Working around not displaying default exception in IHttpAsyncHandler
var errors = razorPage.CompileException.Results.Errors;
for (var i = 0; i < errors.Count; i++)
{
var error = errors[i];
Log.Debug("{0} Line: {1}:{2}:".Fmt(error.FileName, error.Line, error.Column));
Log.Debug("{0}: {1}".Fmt(error.ErrorNumber, error.ErrorText));
}
}
throw razorPage.CompileException;
}
//else, EnsureCompiled() ensures we have a page type to work with so, create an instance of the page
var page = (IRazorView)razorPage.ActivateInstance();
page.Init(viewEngine: this, httpReq: httpReq, httpRes: httpRes);
//deserialize the model.
PrepareAndSetModel(page, httpReq, dto);
return page;
}