本文整理汇总了C#中IViewEngineHost类的典型用法代码示例。如果您正苦于以下问题:C# IViewEngineHost类的具体用法?C# IViewEngineHost怎么用?C# IViewEngineHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IViewEngineHost类属于命名空间,在下文中一共展示了IViewEngineHost类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MarkdownViewEngineHost
public MarkdownViewEngineHost(IViewEngineHost viewEngineHost, IRenderContext renderContext)
{
this.viewEngineHost = viewEngineHost;
this.renderContext = renderContext;
this.Context = this.renderContext.Context;
this.parser = new MarkdownSharp.Markdown();
}
开发者ID:jchannon,项目名称:Nancy.ViewEngines.Markdown,代码行数:7,代码来源:MarkdownViewEngineHost.cs
示例2: MarkdownViewEngineHost
/// <summary>
/// Initializes a new instance of the <see cref="MarkdownViewEngineHost"/> class.
/// </summary>
/// <param name="viewEngineHost">A decorator <see cref="IViewEngineHost"/></param>
/// <param name="renderContext">The render context.</param>
/// <param name="viewExtensions">The allowed extensions</param>
public MarkdownViewEngineHost(IViewEngineHost viewEngineHost, IRenderContext renderContext, IEnumerable<string> viewExtensions)
{
this.viewEngineHost = viewEngineHost;
this.renderContext = renderContext;
this.validExtensions = viewExtensions;
this.Context = this.renderContext.Context;
this.parser = new MarkdownSharp.Markdown();
}
开发者ID:jbattermann,项目名称:Nancy,代码行数:14,代码来源:MarkdownViewEngineHost.cs
示例3: SuperSimpleViewEngine
/// <summary>
/// Initializes a new instance of the <see cref="SuperSimpleViewEngine"/> class.
/// </summary>
public SuperSimpleViewEngine(IViewEngineHost viewEngineHost)
{
this.viewEngineHost = viewEngineHost;
this.processors = new List<Func<string, object, string>>
{
this.PerformSingleSubstitutions,
this.PerformEachSubstitutions,
this.PerformConditionalSubstitutions,
this.PerformPartialSubstitutions,
this.PerformMasterPageSubstitutions,
};
}
开发者ID:nuxleus,项目名称:Nancy,代码行数:16,代码来源:SuperSimpleViewEngine.cs
示例4: PerformPathSubstitutions
/// <summary>
/// Perform path expansion substitutions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with paths expanded</returns>
private static string PerformPathSubstitutions(string template, object model, IViewEngineHost host)
{
var result = template;
result = PathExpansionRegEx.Replace(
result,
m =>
{
var path = m.Groups["Path"].Value;
return host.ExpandPath(path);
});
return result;
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:22,代码来源:SuperSimpleViewEngine.cs
示例5: PerformConditionalSubstitutions
/// <summary>
/// Performs @If.PropertyName and @IfNot.PropertyName substitutions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with @If.PropertyName @IfNot.PropertyName blocks removed/expanded.</returns>
private static string PerformConditionalSubstitutions(string template, object model, IViewEngineHost host)
{
var result = template;
result = ConditionalSubstitutionRegEx.Replace(
result,
m =>
{
var properties = GetCaptureGroupValues(m, "ParameterName");
var modelSource = GetCaptureGroupValues(m, "ModelSource").SingleOrDefault();
if (modelSource != null && modelSource.Equals("Context", StringComparison.OrdinalIgnoreCase))
{
model = host.Context;
}
var predicateResult = GetPredicateResult(model, properties, m.Groups["Null"].Value == "Null");
if (m.Groups["Not"].Value == "Not")
{
predicateResult = !predicateResult;
}
return predicateResult ? m.Groups["Contents"].Value : string.Empty;
});
return result;
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:36,代码来源:SuperSimpleViewEngine.cs
示例6: PerformAntiForgeryTokenSubstitutions
/// <summary>
/// Perform CSRF anti forgery token expansions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with anti forgery tokens expanded</returns>
private static string PerformAntiForgeryTokenSubstitutions(string template, object model, IViewEngineHost host)
{
return AntiForgeryTokenRegEx.Replace(template, x => host.AntiForgeryToken());
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:11,代码来源:SuperSimpleViewEngine.cs
示例7: Render
/// <summary>
/// Renders a template
/// </summary>
/// <param name="template">The template to render.</param>
/// <param name="model">The model to user for rendering.</param>
/// <param name="host">The view engine host</param>
/// <returns>A string containing the expanded template.</returns>
public string Render(string template, dynamic model, IViewEngineHost host)
{
var output =
this.processors.Aggregate(template, (current, processor) => processor(current, model ?? new object(), host));
return this.matchers.Aggregate(output, (current, extension) => extension.Invoke(current, model, host));
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:14,代码来源:SuperSimpleViewEngine.cs
示例8: PerformPartialSubstitutions
/// <summary>
/// Perform @Partial partial view expansion
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with partials expanded</returns>
private string PerformPartialSubstitutions(string template, dynamic model, IViewEngineHost host)
{
var result = template;
result = PartialSubstitutionRegEx.Replace(
result,
m =>
{
var partialViewName = m.Groups["ViewName"].Value;
var partialModel = model;
var properties = GetCaptureGroupValues(m, "ParameterName");
if (m.Groups["Model"].Length > 0)
{
var modelValue = GetPropertyValueFromParameterCollection(partialModel, properties);
if (modelValue.Item1 != true)
{
return "[ERR!]";
}
partialModel = modelValue.Item2;
}
var partialTemplate = host.GetTemplate(partialViewName, partialModel);
return this.Render(partialTemplate, partialModel, host);
});
return result;
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:38,代码来源:SuperSimpleViewEngine.cs
示例9: PerformEachSubstitutions
/// <summary>
/// Performs @Each.PropertyName substitutions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with @Each.PropertyName blocks expanded.</returns>
private string PerformEachSubstitutions(string template, object model, IViewEngineHost host)
{
return EachSubstitutionRegEx.Replace(
template,
m =>
{
var properties = GetCaptureGroupValues(m, "ParameterName");
var modelSource = GetCaptureGroupValues(m, "ModelSource").SingleOrDefault();
if (modelSource != null && modelSource.Equals("Context", StringComparison.OrdinalIgnoreCase))
{
model = host.Context;
}
var substitutionObject = GetPropertyValueFromParameterCollection(model, properties);
if (substitutionObject.Item1 == false)
{
return "[ERR!]";
}
if (substitutionObject.Item2 == null)
{
return string.Empty;
}
var substitutionEnumerable = substitutionObject.Item2 as IEnumerable;
if (substitutionEnumerable == null)
{
return "[ERR!]";
}
var contents = m.Groups["Contents"].Value;
var result = string.Empty;
foreach (var item in substitutionEnumerable)
{
var modifiedContent = PerformPartialSubstitutions(contents, item, host);
modifiedContent = PerformConditionalSubstitutions(modifiedContent, item, host);
result += ReplaceCurrentMatch(modifiedContent, item, host);
}
return result;
});
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:53,代码来源:SuperSimpleViewEngine.cs
示例10: PerformConditionalSubstitutions
/// <summary>
/// Performs @If.PropertyName and @IfNot.PropertyName substitutions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with @If.PropertyName @IfNot.PropertyName blocks removed/expanded.</returns>
private string PerformConditionalSubstitutions(string template, object model, IViewEngineHost host)
{
var result = template;
result = ConditionalSubstitutionRegEx.Replace(
result,
m =>
{
var properties = GetCaptureGroupValues(m, "ParameterName");
var predicateResult = GetPredicateResult(model, properties);
if (m.Groups["Not"].Value == "Not")
{
predicateResult = !predicateResult;
}
return predicateResult ? m.Groups["Contents"].Value : string.Empty;
});
return result;
}
开发者ID:ryanki1,项目名称:Nancy,代码行数:29,代码来源:SuperSimpleViewEngine.cs
示例11: Render
/// <summary>
/// Renders a template
/// </summary>
/// <param name="template">The template to render.</param>
/// <param name="model">The model to user for rendering.</param>
/// <param name="host">The view engine host</param>
/// <returns>A string containing the expanded template.</returns>
public string Render(string template, dynamic model, IViewEngineHost host)
{
return this.processors.Aggregate(template, (current, processor) => processor(current, model ?? new object(), host));
}
开发者ID:ryanki1,项目名称:Nancy,代码行数:11,代码来源:SuperSimpleViewEngine.cs
示例12: PerformPathSubstitutions
/// <summary>
/// Perform path expansion substitutions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with paths expanded</returns>
private static string PerformPathSubstitutions(string template, object model, IViewEngineHost host)
{
var result = template;
result = PathExpansionRegEx.Replace(
result,
m =>
{
var path = m.Groups["Path"].Value;
return host.ExpandPath(path);
});
result = AttributeValuePathExpansionRegEx.Replace(
result,
m =>
{
var attribute = m.Groups["Attribute"];
var quote = m.Groups["Quote"].Value;
var path = m.Groups["Path"].Value;
var expandedPath = host.ExpandPath(path);
return string.Format("{0}={1}{2}{1}", attribute, quote, expandedPath);
});
return result;
}
开发者ID:LinuxDoku,项目名称:Nancy,代码行数:35,代码来源:SuperSimpleViewEngine.cs
示例13: Invoke
public string Invoke(string p_Content, dynamic p_Model, IViewEngineHost p_Host)
{
return p_Content.Replace("@GrooveCaster.Version", Application.GetVersion());
}
开发者ID:WildGenie,项目名称:GrooveCaster,代码行数:4,代码来源:GrooveCasterMatcher.cs
示例14: MarkdownViewEngineHost
public MarkdownViewEngineHost(IViewEngineHost viewEngineHost, IRenderContext renderContext)
{
this.viewEngineHost = viewEngineHost;
this.renderContext = renderContext;
this.Context = this.renderContext.Context;
}
开发者ID:phillip-haydon,项目名称:Nancy.ViewEngines.Markdown,代码行数:6,代码来源:MarkdownViewEngineHost.cs
示例15: PerformViewBagSubstitutions
/// <summary>
/// Performs single @ViewBag.PropertyName substitutions.
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">This parameter is not used, the model is based on the "host.Context.ViewBag".</param>
/// <param name="host">View engine host</param>
/// <returns>Template with @ViewBag.PropertyName blocks expanded.</returns>
private static string PerformViewBagSubstitutions(string template, object model, IViewEngineHost host)
{
return ViewBagSubstitutionsRegEx.Replace(
template,
m =>
{
var properties = GetCaptureGroupValues(m, "ParameterName");
var substitution = GetPropertyValueFromParameterCollection(((dynamic)host.Context).ViewBag, properties);
if (!substitution.Item1)
{
return "[ERR!]";
}
if (substitution.Item2 == null)
{
return string.Empty;
}
return m.Groups["Encode"].Success ? host.HtmlEncode(substitution.Item2.ToString()) : substitution.Item2.ToString();
});
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:30,代码来源:SuperSimpleViewEngine.cs
示例16: ReplaceCurrentMatch
/// <summary>
/// Expand a @Current match inside an @Each iterator
/// </summary>
/// <param name="contents">Contents of the @Each block</param>
/// <param name="item">Current item from the @Each enumerable</param>
/// <param name="host">View engine host</param>
/// <returns>String result of the expansion of the @Each.</returns>
private static string ReplaceCurrentMatch(string contents, object item, IViewEngineHost host)
{
return EachItemSubstitutionRegEx.Replace(
contents,
eachMatch =>
{
if (string.IsNullOrEmpty(eachMatch.Groups["ParameterName"].Value))
{
return eachMatch.Groups["Encode"].Success ? host.HtmlEncode(item.ToString()) : item.ToString();
}
var properties = GetCaptureGroupValues(eachMatch, "ParameterName");
var substitution = GetPropertyValueFromParameterCollection(item, properties);
if (!substitution.Item1)
{
return "[ERR!]";
}
if (substitution.Item2 == null)
{
return string.Empty;
}
return eachMatch.Groups["Encode"].Success ? host.HtmlEncode(substitution.Item2.ToString()) : substitution.Item2.ToString();
});
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:35,代码来源:SuperSimpleViewEngine.cs
示例17: PerformEachSubstitutions
/// <summary>
/// Performs @Each.PropertyName substitutions
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with @Each.PropertyName blocks expanded.</returns>
private string PerformEachSubstitutions(string template, object model, IViewEngineHost host)
{
return EachSubstitutionRegEx.Replace(
template,
m =>
{
var properties = GetCaptureGroupValues(m, "ParameterName");
var substitutionObject = GetPropertyValueFromParameterCollection(model, properties);
if (substitutionObject.Item1 == false)
{
return "[ERR!]";
}
if (substitutionObject.Item2 == null)
{
return string.Empty;
}
var substitutionEnumerable = substitutionObject.Item2 as IEnumerable;
if (substitutionEnumerable == null)
{
return "[ERR!]";
}
var contents = m.Groups["Contents"].Value;
var result = string.Empty;
foreach (var item in substitutionEnumerable)
{
result += ReplaceCurrentMatch(contents, item, host);
}
return result;
});
}
开发者ID:ryanki1,项目名称:Nancy,代码行数:43,代码来源:SuperSimpleViewEngine.cs
示例18: PerformMasterPageSubstitutions
/// <summary>
/// Invokes the master page rendering with current sections if necessary
/// </summary>
/// <param name="template">The template.</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with master page applied and sections substituted</returns>
private string PerformMasterPageSubstitutions(string template, object model, IViewEngineHost host)
{
var masterPageName = GetMasterPageName(template);
if (string.IsNullOrWhiteSpace(masterPageName))
{
return template;
}
var masterTemplate = host.GetTemplate(masterPageName, model);
var sectionMatches = SectionContentsRegEx.Matches(template);
var sections = sectionMatches.Cast<Match>().ToDictionary(sectionMatch => sectionMatch.Groups["SectionName"].Value, sectionMatch => sectionMatch.Groups["SectionContents"].Value);
return this.RenderMasterPage(masterTemplate, sections, model, host);
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:22,代码来源:SuperSimpleViewEngine.cs
示例19: RenderMasterPage
/// <summary>
/// Renders a master page - does a normal render then replaces any section tags with sections passed in
/// </summary>
/// <param name="masterTemplate">The master page template</param>
/// <param name="sections">Dictionary of section contents</param>
/// <param name="model">The model.</param>
/// <param name="host">View engine host</param>
/// <returns>Template with the master page applied and sections substituted</returns>
private string RenderMasterPage(string masterTemplate, IDictionary<string, string> sections, object model, IViewEngineHost host)
{
var result = this.Render(masterTemplate, model, host);
result = SectionDeclarationRegEx.Replace(
result,
m =>
{
var sectionName = m.Groups["SectionName"].Value;
return sections.ContainsKey(sectionName) ? sections[sectionName] : string.Empty;
});
return result;
}
开发者ID:marcusoftnet,项目名称:Nancy,代码行数:23,代码来源:SuperSimpleViewEngine.cs
示例20: SuperSimpleViewEngineTests
public SuperSimpleViewEngineTests()
{
this.fakeHost = new FakeViewEngineHost();
this.viewEngine = new SuperSimpleViewEngine(Enumerable.Empty<ISuperSimpleViewEngineMatcher>());
}
开发者ID:kppullin,项目名称:Nancy,代码行数:5,代码来源:SuperSimpleViewEngineTests.cs
注:本文中的IViewEngineHost类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论