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
82 lines (70 loc) · 1.99 KB
/
Copy pathViewPage.cs
File metadata and controls
82 lines (70 loc) · 1.99 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
using System;
using System.IO;
using System.Web;
using System.Globalization;
using System.Collections.Generic;
using ServiceStack.Html;
using ServiceStack.MiniProfiler;
using ServiceStack.Razor.Templating;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints.Support.Markdown;
namespace ServiceStack.Razor
{
public abstract class ViewPage : ViewPageBase<DynamicRequestObject>
{
public HtmlHelper Html = new HtmlHelper();
private IViewEngine viewEngine;
public override IViewEngine ViewEngine
{
get { return viewEngine; }
set
{
Html.ViewEngine = viewEngine = value;
}
}
public new dynamic Model { get; set; }
public override Type ModelType
{
get { return typeof(DynamicRequestObject); }
}
public override void Init(IRazorViewEngine viewEngine, ViewDataDictionary viewData, IHttpRequest httpReq, IHttpResponse httpRes)
{
this.Request = httpReq;
this.Response = httpRes;
Html.Init(viewEngine, viewData);
this.Model = new DynamicRequestObject(httpReq);
}
public virtual bool IsSectionDefined(string sectionName)
{
//return this.childSections.ContainsKey(sectionName);
return false;
}
public virtual void DefineSection(string sectionName, Action action)
{
//this.Sections.Add(sectionName, action);
}
private static string HtmlEncode(object value)
{
if (value == null)
{
return null;
}
var str = value as System.Web.IHtmlString;
return str != null ? str.ToHtmlString() : HttpUtility.HtmlEncode(Convert.ToString(value, CultureInfo.CurrentCulture));
}
public virtual void WriteTo(TextWriter writer, HelperResult value)
{
if (value != null)
{
value.WriteTo(writer);
}
}
public virtual void WriteLiteralTo(TextWriter writer, HelperResult value)
{
if (value != null)
{
value.WriteTo(writer);
}
}
}
}