forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewPage.cs
More file actions
88 lines (73 loc) · 2.37 KB
/
ViewPage.cs
File metadata and controls
88 lines (73 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.IO;
using ServiceStack.Html;
using ServiceStack.Web;
namespace ServiceStack.Razor
{
public abstract class ViewPage : ViewPageBase<dynamic>, IRazorView
{
public HtmlHelper Html = new HtmlHelper();
public override Type ModelType
{
get { return typeof(DynamicRequestObject); }
}
public void Init(IViewEngine viewEngine, IRequest httpReq, IResponse httpRes)
{
base.Request = httpReq;
base.Response = httpRes;
Html.Init(viewEngine: viewEngine, httpReq: httpReq, httpRes: httpRes, razorPage:this);
}
public override void SetModel(object o)
{
base.SetModel(o);
Html.SetModel(o);
}
public void WriteTo(StreamWriter writer)
{
this.Output = Html.Writer = writer;
this.Execute();
this.Output.Flush();
}
}
public abstract class ViewPage<TModel> : ViewPageBase<TModel>, IRazorView
{
public HtmlHelper<TModel> Html = new HtmlHelper<TModel>();
public int Counter { get; set; }
public HtmlHelper HtmlHelper
{
get { return Html; }
}
public void Init(IViewEngine viewEngine, IRequest httpReq, IResponse httpRes)
{
base.Request = httpReq;
base.Response = httpRes;
Html.Init(viewEngine: viewEngine, httpReq: httpReq, httpRes: httpRes, razorPage: this);
}
public override void SetModel(object o)
{
base.SetModel(o);
Html.SetModel(o);
}
public void WriteTo(StreamWriter writer)
{
this.Output = Html.Writer = writer;
this.Execute();
this.Output.Flush();
}
public override Type ModelType
{
get { return typeof(TModel); }
}
//public override void Init(IRazorViewEngine viewEngine, ViewDataDictionary viewData, IHttpRequest httpReq, IHttpResponse httpRes)
//{
// this.Request = httpReq;
// this.Response = httpRes;
// Html = new HtmlHelper<TModel>();
// Html.Init(httpReq, httpRes, viewEngine, viewData, null);
// if (viewData.Model is TModel)
// this.Model = (TModel)viewData.Model;
// else
// this.ModelError = viewData.Model;
//}
}
}