本文整理汇总了C#中NVelocity.App.VelocityEngine.SetApplicationAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# VelocityEngine.SetApplicationAttribute方法的具体用法?C# VelocityEngine.SetApplicationAttribute怎么用?C# VelocityEngine.SetApplicationAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NVelocity.App.VelocityEngine
的用法示例。
在下文中一共展示了VelocityEngine.SetApplicationAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetStylesheet
/// <summary>
/// <p>
/// Sets the stylesheet for this transformation set
/// </p>
///
/// <p>
/// Note that don't need this for each document you want
/// to transform. Just do it once, and transform away...
/// </p>
/// </summary>
/// <param name="styleReader">Reader with stylesheet char stream</param>
public virtual void SetStylesheet(TextReader value) {
ready = false;
/*
* now initialize Velocity - we need to do that
* on change of stylesheet
*/
ve = new VelocityEngine();
/*
* if there are user properties, set those first - carefully
*/
if (velConfig != null) {
ConfigureVelocityEngine(ve, velConfig);
}
/*
* register our template() directive
*/
ve.SetProperty("userdirective", @"NVelocity.Dvsl.Directive.MatchDirective\,NVelocity");
ve.Init();
/*
* add our template accumulator
*/
ve.SetApplicationAttribute("NVelocity.Dvsl.TemplateHandler", templateHandler);
/*
* load and render the stylesheet
*
* this sets stylesheet specific context
* values
*/
StringWriter junkWriter = new StringWriter();
styleContext = new VelocityContext();
ve.Evaluate(styleContext, junkWriter, "DVSL:stylesheet", value);
/*
* now run the base template through for the rules
*/
// TODO - use ResourceLocator or something else - I don't like the path to the resource
Stream s = this.GetType().Assembly.GetManifestResourceStream("NVelocity.Dvsl.Resource.defaultroot.dvsl");
if (s == null) {
System.Console.Out.WriteLine("DEFAULT TRANSFORM RULES NOT FOUND ");
} else {
ve.Evaluate(new VelocityContext(), junkWriter, "defaultroot.dvsl", new StreamReader(s));
s.Close();
}
/*
* need a new transformer, as it depends on the
* velocity engine
*/
transformer = new Transformer(ve, templateHandler, baseContext, appVals, validate);
}
示例2: InitSpringResourceLoader
protected void InitSpringResourceLoader(VelocityEngine velocityEngine, ExtendedProperties extendedProperties, string resourceLoaderPathString)
{
extendedProperties.SetProperty(RuntimeConstants.RESOURCE_LOADER, SpringResourceLoader.NAME);
Type springResourceLoaderType = typeof(SpringResourceLoader);
string springResourceLoaderTypeName = springResourceLoaderType.FullName + "; " + springResourceLoaderType.Assembly.GetName().Name;
extendedProperties.SetProperty(SpringResourceLoader.SPRING_RESOURCE_LOADER_CLASS, springResourceLoaderTypeName);
velocityEngine.SetApplicationAttribute(SpringResourceLoader.SPRING_RESOURCE_LOADER, ResourceLoader);
velocityEngine.SetApplicationAttribute(SpringResourceLoader.SPRING_RESOURCE_LOADER_PATH, resourceLoaderPathString);
}