当前位置: 首页>>代码示例>>C#>>正文


C# VelocityEngine.SetApplicationAttribute方法代码示例

本文整理汇总了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);
	}
开发者ID:DF-thangld,项目名称:web_game,代码行数:73,代码来源:Dvsl.cs

示例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);
 }
开发者ID:Binodesk,项目名称:spring-net,代码行数:9,代码来源:VelocityEngineFactory.cs


注:本文中的NVelocity.App.VelocityEngine.SetApplicationAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。