本文整理汇总了C#中TemplateService.SetTemplateBase方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateService.SetTemplateBase方法的具体用法?C# TemplateService.SetTemplateBase怎么用?C# TemplateService.SetTemplateBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateService
的用法示例。
在下文中一共展示了TemplateService.SetTemplateBase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseStyle
/// <summary>
/// Uses the style.
/// </summary>
/// <param name="styleName">Name of the style.</param>
/// <returns></returns>
internal void UseStyle(string styleName)
{
razorCompiler = new DefaultCompilerServiceFactory();
razor = new TemplateService(razorCompiler.CreateCompilerService(Language.CSharp, false, null), null);
razor.SetTemplateBase(typeof(TemplateHelperBase));
razor.AddResolver(this);
if (!StyleManager.StyleExist(styleName))
Logger.Fatal("Cannot us style [{0}]. Style doesn't exist", styleName);
CurrentStyleName = styleName;
StyleDirectories.Clear();
var includeBaseStyle = new List<string>();
var styles = StyleManager.AvailableStyles;
includeBaseStyle.Add(styleName);
bool isNotComplete = true;
// Compute directories to look, by following inheritance
// In the same order they are declared
while (isNotComplete)
{
isNotComplete = false;
// Build directories to look for this specific style and all its base style);
var toRemove = new List<StyleDefinition>();
foreach (var style in styles)
{
// Apply parameter inherited from style
if (style.Name == styleName)
{
foreach (var parameter in style.Parameters)
{
((DynamicParam)Param).Properties.Remove(parameter.Name);
((DynamicParam)Param).Properties.Add(parameter.Name, parameter.value);
}
}
if (includeBaseStyle.Contains(style.Name))
{
toRemove.Add(style);
StyleDirectories.Add(style.DirectoryPath);
isNotComplete = true;
if (style.HasBaseStyle)
includeBaseStyle.Add(style.BaseStyle);
}
}
// Remove the style that was processed by the previous loop
foreach (var styleDefinition in toRemove)
styles.Remove(styleDefinition);
}
foreach (var styleDirectory in StyleDirectories)
{
Logger.Message("Using Style Directory [{0}]", styleDirectory);
}
}