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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Security.Principal;
using System.Threading;
using System.Web.Caching;
using System.Web.Profile;
using Microsoft.Internal.Web.Utils;
namespace System.Web.WebPages
{
public abstract class WebPageRenderingBase : WebPageExecutingBase, ITemplateFile
{
private IPrincipal _user;
private UrlDataList _urlData;
private TemplateFileInfo _templateFileInfo;
private DisplayModeProvider _displayModeProvider;
public virtual Cache Cache
{
get
{
if (Context != null)
{
return Context.Cache;
}
return null;
}
}
internal DisplayModeProvider DisplayModeProvider
{
get { return _displayModeProvider ?? DisplayModeProvider.Instance; }
set { _displayModeProvider = value; }
}
protected internal IDisplayMode DisplayMode
{
get { return DisplayModeProvider.GetDisplayMode(Context); }
}
public abstract string Layout { get; set; }
public abstract IDictionary<object, dynamic> PageData { get; }
public abstract dynamic Page { get; }
public WebPageContext PageContext { get; internal set; }
public ProfileBase Profile
{
get
{
if (Context != null)
{
return Context.Profile;
}
return null;
}
}
public virtual HttpRequestBase Request
{
get
{
if (Context != null)
{
return Context.Request;
}
return null;
}
}
public virtual HttpResponseBase Response
{
get
{
if (Context != null)
{
return Context.Response;
}
return null;
}
}
public virtual HttpServerUtilityBase Server
{
get
{
if (Context != null)
{
return Context.Server;
}
return null;
}
}
public virtual HttpSessionStateBase Session
{
get
{
if (Context != null)
{
return Context.Session;
}
return null;
}
}
public virtual IList<string> UrlData
{
get
{
if (_urlData == null)
{
WebPageMatch match = WebPageRoute.GetWebPageMatch(Context);
if (match != null)
{
_urlData = new UrlDataList(match.PathInfo);
}
else
{
// REVIEW: Can there ever be no route match?
_urlData = new UrlDataList(null);
}
}
return _urlData;
}
}
public virtual IPrincipal User
{
get
{
if (_user == null)
{
return Context.User;
}
return _user;
}
internal set { _user = value; }
}
public virtual TemplateFileInfo TemplateInfo
{
get
{
if (_templateFileInfo == null)
{
_templateFileInfo = new TemplateFileInfo(VirtualPath);
}
return _templateFileInfo;
}
}
public virtual bool IsPost
{
get { return Request.HttpMethod == "POST"; }
}
public virtual bool IsAjax
{
get
{
var request = Request;
if (request == null)
{
return false;
}
return (request["X-Requested-With"] == "XMLHttpRequest") || ((request.Headers != null) && (request.Headers["X-Requested-With"] == "XMLHttpRequest"));
}
}
public string Culture
{
get { return Thread.CurrentThread.CurrentCulture.Name; }
set
{
if (String.IsNullOrEmpty(value))
{
// GetCultureInfo accepts empty strings but throws for null strings. To maintain consistency in our string handling behavior, throw
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "value");
}
CultureUtil.SetCulture(Thread.CurrentThread, Context, value);
}
}
public string UICulture
{
get { return Thread.CurrentThread.CurrentUICulture.Name; }
set
{
if (String.IsNullOrEmpty(value))
{
// GetCultureInfo accepts empty strings but throws for null strings. To maintain consistency in our string handling behavior, throw
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "value");
}
CultureUtil.SetUICulture(Thread.CurrentThread, Context, value);
}
}
// Calls the Execute() method, and calls RunPage() if the page is an InitPage but
// did not call RunPage().
public abstract void ExecutePageHierarchy();
public abstract HelperResult RenderPage(string path, params object[] data);
}
}
|