本文整理汇总了C#中Commons.Collections.ExtendedProperties.AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C# ExtendedProperties.AddProperty方法的具体用法?C# ExtendedProperties.AddProperty怎么用?C# ExtendedProperties.AddProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commons.Collections.ExtendedProperties
的用法示例。
在下文中一共展示了ExtendedProperties.AddProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NVelocityHelper
static NVelocityHelper()
{
_velocity = new VelocityEngine();
var props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, ConfigurationManager.AppSettings["TemplateFolder"]);
_velocity.Init(props);
}
示例2: GetBasicProperties
private static ExtendedProperties GetBasicProperties()
{
ExtendedProperties properties = new ExtendedProperties();
properties.AddProperty("resource.loader", "assembly");
properties.AddProperty("assembly.resource.loader.class",
"NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader, NVelocity");
return properties;
}
示例3: TemplateHelper
public TemplateHelper(string templatePath)
{
velocity = new VelocityEngine();
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatePath);
props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
velocity.Init(props);
context = new VelocityContext();
}
示例4: Apply
public void Apply(IEnumerable<ChangeScript> changeScripts)
{
string filename = string.Format(CultureInfo.InvariantCulture, "{0}_{1}.vm", this.syntax, this.GetTemplateQualifier());
var model = new Hashtable();
model.Add("scripts", changeScripts);
model.Add("changeLogTableName", this.changeLogTableName);
model.Add("delimiter", this.delimiter);
model.Add("separator", this.delimiterType is RowDelimiter ? Environment.NewLine : string.Empty);
try
{
ExtendedProperties props = new ExtendedProperties();
var assemblyName = typeof(TemplateBasedApplier).Assembly.GetName().Name;
ReplaceManagersWithDbDeployVersions(props, assemblyName);
if (this.templateDirectory == null)
{
props.AddProperty("resource.loader", "assembly");
// The ";" will be replaced by "," in the resource loader factory.
// This is because if we add a property with a comma in the value, it will add *two* values to the property.
props.AddProperty(
"assembly.resource.loader.class",
typeof(DbDeployAssemblyResourceLoader).FullName + "; " + assemblyName);
props.AddProperty("assembly.resource.loader.assembly", assemblyName);
filename = "Net.Sf.Dbdeploy.Resources." + filename;
}
else
{
props.SetProperty("file.resource.loader.path", this.templateDirectory.FullName);
}
var templateEngine = new VelocityEngine(props);
var context = new VelocityContext(model);
Template template = templateEngine.GetTemplate(filename);
template.Merge(context, this.writer);
}
catch (ResourceNotFoundException ex)
{
string locationMessage = templateDirectory == null
? string.Empty
: (" at " + templateDirectory.FullName);
throw new UsageException(
"Could not find template named " + filename + locationMessage + Environment.NewLine + "Check that you have got the name of the database syntax correct.",
ex);
}
}
示例5: NVelocity
static NVelocity()
{
filePath = Utils.GetMapPath(BaseConfigs.GetForumPath);
engine = new VelocityEngine();
props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, filePath);
engine.Init(props);
}
示例6: NVelocityViewEngine
/// <summary>
/// Initializes a new instance of the <see cref="NVelocityViewEngine"/> class.
/// </summary>
/// <param name="assemblies">The assemblies.</param>
/// <param name="extensionMethodTypes">The extension method types.</param>
public NVelocityViewEngine(IEnumerable<Assembly> assemblies, params Type[] extensionMethodTypes)
{
var properties = new ExtendedProperties();
properties.AddProperty("resource.loader", "parials");
properties.AddProperty("parials.resource.loader.class", typeof(PartialFileResourceLoader).AssemblyQualifiedName.Replace(",", ";"));
properties.AddProperty("parials.resource.loader.assembly", assemblies.Select(a => a.FullName).ToList());
_engine = new VelocityEngine();
_engine.Init(properties);
_extensionMethods = extensionMethodTypes.SelectMany(type => type.GetMethods(BindingFlags.Public | BindingFlags.Static)).Select(method => new DynamicDispatchMethod(method)).ToArray();
}
示例7: Init
public void Init(string virtualDir)
{
//创建VelocityEngine实例对象
velocity = new VelocityEngine();
//使用设置初始化VelocityEngine
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, string.Format("{0}\\{1}", Root.TrimEnd('\\'), virtualDir));
props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
// props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
velocity.Init(props);
//为模板变量赋值
context = new VelocityContext();
}
示例8: Init
/// <summary>
/// 初始话NVelocity模块
/// </summary>
/// <param name="templatDir">模板文件夹路径</param>
public void Init(string templatDir)
{
//创建VelocityEngine实例对象
_velocity = new VelocityEngine();
//使用设置初始化VelocityEngine
var props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatDir);
props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
_velocity.Init(props);
//为模板变量赋值
_context = new VelocityContext();
}
示例9: RenderTemplate
public string RenderTemplate(string masterPage, string templateName, IDictionary<string, object> data)
{
if (string.IsNullOrEmpty(templateName))
{
throw new ArgumentException("The \"templateName\" parameter must be specified", "templateName");
}
var name = !string.IsNullOrEmpty(masterPage)
? masterPage : templateName;
var engine = new VelocityEngine();
var props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, _templatesPath);
engine.Init(props);
var template = engine.GetTemplate(name);
template.Encoding = Encoding.UTF8.BodyName;
var context = new VelocityContext();
var templateData = data ?? new Dictionary<string, object>();
foreach (var key in templateData.Keys)
{
context.Put(key, templateData[key]);
}
if (!string.IsNullOrEmpty(masterPage))
{
context.Put("childContent", templateName);
}
using (var writer = new StringWriter())
{
engine.MergeTemplate(name, context, writer);
return writer.GetStringBuilder().ToString();
}
}
示例10: Test
public void Test()
{
var vlte = new VelocityEngine();
var props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, AppDomain.CurrentDomain.BaseDirectory);
vlte.Init(props);
var vlc = new VelocityContext();
vlc.Put("test", "test");
var vtp = vlte.GetTemplate("NVelocityTest.vm");
var str = new StringWriter();
vtp.Merge(vlc, str);
Console.WriteLine(str.GetStringBuilder().ToString());
}
示例11: Format
public static string Format(HttpContext context, string pattern, VelocityContext velocitycontext)
{
using (var writer = new StringWriter())
{
try
{
if (!_isInitialized)
{
var props = new ExtendedProperties();
props.AddProperty("file.resource.loader.path",
new ArrayList(new[]
{
".",
Path.Combine(
context.Server.MapPath(feed.HandlerBasePath),
"Patterns")
}));
Velocity.Init(props);
_isInitialized = true;
}
//Load patterns
var template = Patterns.Get(pattern, () => LoadTemplate(pattern));
template.Merge(velocitycontext, writer);
return writer.GetStringBuilder().ToString();
}
catch (Exception)
{
//Format failed some way
return writer.GetStringBuilder().ToString();
}
}
}
示例12: Init
public void Init()
{
_velocity = new VelocityEngine();
var properties = new ExtendedProperties();
properties.AddProperty(
"resource.loader",
"assembly");
properties.AddProperty(
"assembly.resource.loader.class",
"NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader, NVelocity");
properties.AddProperty(
"assembly.resource.loader.assembly",
"CrystalQuartz.Web");
_velocity.Init(properties);
}
示例13: NVelocityTemplateRepository
public NVelocityTemplateRepository(string templateDirectory)
{
engine = new VelocityEngine();
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDirectory);
engine.Init(props);
}
示例14: Configure
public virtual bool Configure()
{
_engine = new VelocityEngine();
var props = new ExtendedProperties();
props.AddProperty("file.resource.loader.path", TemplatePath);
_engine.Init(props);
return true;
}
示例15: FillResponseTemplate
public virtual string FillResponseTemplate(IDictionary<string, object> viewParams)
{
var engine = new VelocityEngine();
var props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "assembly");
props.AddProperty("assembly.resource.loader.class",
"NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader, NVelocity");
props.AddProperty("assembly.resource.loader.assembly", GetType().Assembly.FullName);
engine.Init(props);
var vcontext = new VelocityContext();
foreach (var k in viewParams) {
vcontext.Put(k.Key, k.Value);
}
using (var writer = new StringWriter()) {
engine.GetTemplate(ViewName).Merge(vcontext, writer);
return writer.GetStringBuilder().ToString();
}
}