annotate src/Web/RazorEngine.Mvc/MvcTemplateBase.cs @ 2:b0419fdcff0b

Правка зависимостей
author Andre K <m407@mail.ru>
date Sat, 13 Dec 2014 18:14:19 +0300
parents 5bca2d201ad8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5bca2d201ad8 initial commit
cin
parents:
diff changeset
1 namespace RazorEngine.Mvc
5bca2d201ad8 initial commit
cin
parents:
diff changeset
2 {
5bca2d201ad8 initial commit
cin
parents:
diff changeset
3 using System;
5bca2d201ad8 initial commit
cin
parents:
diff changeset
4 using System.Web;
5bca2d201ad8 initial commit
cin
parents:
diff changeset
5 using System.Web.Mvc;
5bca2d201ad8 initial commit
cin
parents:
diff changeset
6
5bca2d201ad8 initial commit
cin
parents:
diff changeset
7 using Templating;
5bca2d201ad8 initial commit
cin
parents:
diff changeset
8
5bca2d201ad8 initial commit
cin
parents:
diff changeset
9 /// <summary>
5bca2d201ad8 initial commit
cin
parents:
diff changeset
10 /// Provides a base implementation of an MVC-compatible template.
5bca2d201ad8 initial commit
cin
parents:
diff changeset
11 /// </summary>
5bca2d201ad8 initial commit
cin
parents:
diff changeset
12 public abstract class MvcTemplateBase : TemplateBase
5bca2d201ad8 initial commit
cin
parents:
diff changeset
13 {
5bca2d201ad8 initial commit
cin
parents:
diff changeset
14 #region Properties
5bca2d201ad8 initial commit
cin
parents:
diff changeset
15 /// <summary>
5bca2d201ad8 initial commit
cin
parents:
diff changeset
16 /// Gets the <see cref="HtmlHelper{Object}"/> for this template.
5bca2d201ad8 initial commit
cin
parents:
diff changeset
17 /// </summary>
5bca2d201ad8 initial commit
cin
parents:
diff changeset
18 public HtmlHelper<object> Html { get; private set; }
5bca2d201ad8 initial commit
cin
parents:
diff changeset
19
5bca2d201ad8 initial commit
cin
parents:
diff changeset
20 /// <summary>
5bca2d201ad8 initial commit
cin
parents:
diff changeset
21 /// Gets the <see cref="UrlHelper"/> for this template.
5bca2d201ad8 initial commit
cin
parents:
diff changeset
22 /// </summary>
5bca2d201ad8 initial commit
cin
parents:
diff changeset
23 public UrlHelper Url { get; private set; }
5bca2d201ad8 initial commit
cin
parents:
diff changeset
24 #endregion
5bca2d201ad8 initial commit
cin
parents:
diff changeset
25
5bca2d201ad8 initial commit
cin
parents:
diff changeset
26 #region Methods
5bca2d201ad8 initial commit
cin
parents:
diff changeset
27 public void InitHelpers()
5bca2d201ad8 initial commit
cin
parents:
diff changeset
28 {
5bca2d201ad8 initial commit
cin
parents:
diff changeset
29 var httpContext = new HttpContextWrapper(HttpContext.Current);
5bca2d201ad8 initial commit
cin
parents:
diff changeset
30 var handler = httpContext.CurrentHandler as MvcHandler;
5bca2d201ad8 initial commit
cin
parents:
diff changeset
31 if (handler == null)
5bca2d201ad8 initial commit
cin
parents:
diff changeset
32 throw new InvalidOperationException("Unable to run template outside of ASP.NET MVC");
5bca2d201ad8 initial commit
cin
parents:
diff changeset
33 }
5bca2d201ad8 initial commit
cin
parents:
diff changeset
34 #endregion
5bca2d201ad8 initial commit
cin
parents:
diff changeset
35 }
5bca2d201ad8 initial commit
cin
parents:
diff changeset
36 }