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
93 lines (77 loc) · 2.28 KB
/
ViewPage.cs
File metadata and controls
93 lines (77 loc) · 2.28 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
89
90
91
92
93
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 dynamic Context { get; set; } //Unused, make Razor VS.NET Intelli-sense happy
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 override StreamWriter Output
{
get
{
return base.Output;
}
set
{
base.Output = Html.Writer = value;
}
}
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);
if (o is TModel)
{
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); }
}
}
}