本文整理汇总了C#中Commons.Collections.ExtendedProperties类的典型用法代码示例。如果您正苦于以下问题:C# ExtendedProperties类的具体用法?C# ExtendedProperties怎么用?C# ExtendedProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExtendedProperties类属于Commons.Collections命名空间,在下文中一共展示了ExtendedProperties类的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: 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();
}
}
示例3: 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();
}
}
}
示例4: Initialize
public void Initialize()
{
ActiveRecordStarter.Initialize( new XmlConfigurationSource("activeRecord.xml"),
typeof(Acl) ,
typeof(Category) ,
typeof(Chat) ,
typeof(ChatMessage) ,
typeof(ConfigCombo) ,
typeof(ConfigModel) ,
typeof(Container) ,
typeof(Content) ,
typeof(DataModel) ,
typeof(Field) ,
typeof(FieldTemplate) ,
typeof(CastlePortal.File) ,
typeof(Forum) ,
typeof(ForumFolder) ,
typeof(ForumMessage) ,
typeof(Group) ,
typeof(Menu) ,
typeof(Role) ,
typeof(CastlePortal.Template) ,
typeof(CastlePortal.Type) ,
typeof(Language),
typeof(MenuTranslation),
typeof(TypeTranslation),
typeof(User)
);
velocity = new VelocityEngine();
ExtendedProperties props = new ExtendedProperties();
velocity.Init(props);
}
示例5: SetLoaderPath
private void SetLoaderPath(ExtendedProperties properties)
{
string loaderPath = "";
// TODO: Solve multiple loader path problem in NVelocity
if (Template.FileName == "")
{
loaderPath = BaseFolder;
}
else
{
loaderPath = Path.GetDirectoryName(Template.GetFullPath());
if (loaderPath.IndexOf(BaseFolder) < 0 && loaderPath != BaseFolder)
{
loaderPath = BaseFolder + "," + loaderPath;
}
else if (loaderPath != BaseFolder)
{
loaderPath += "," + BaseFolder;
}
}
// HACK: Setting loader path to base folder until loader problem is solved
//loaderPath = BaseFolder;
//System.Diagnostics.Debug.WriteLine("NVeleocity:loaderPath=" + loaderPath);
if (properties.Contains("file.resource.loader.path"))
{
properties["file.resource.loader.path"] = loaderPath;
}
else
{
properties.AddProperty("file.resource.loader.path", loaderPath);
}
}
示例6: InitialiseNVelocity
protected void InitialiseNVelocity(string templatePath) {
ExtendedProperties props = new ExtendedProperties();
props.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, TemplatePath);
Velocity.Init(props);
}
示例7: CreateCode
public static void CreateCode(string filepath, string outputpath, VelocityContext context)
{
StreamWriter writer=null;
try
{
VelocityEngine engine = null;//new VelocityEngine();
ExtendedProperties extendedProperties = new ExtendedProperties();
//extendedProperties.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, filepath.Substring(0, filepath.LastIndexOf("\\")));
engine.Init(extendedProperties);
//Template template = engine.GetTemplate(filepath.Substring(filepath.LastIndexOf("\\")+1));
//FileStream fos = new FileStream(outputpath + "\\1.vm", FileMode.Create);
//writer = new StreamWriter(fos);
//template.Merge(context, writer);
//writer.Flush();
//writer.Close();
StringWriter output=new StringWriter();
engine.Evaluate(context, output, "", filepath);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (writer != null)
{
writer.Close();
}
}
}
示例8: Test
public void Test()
{
var velocityEngine = new VelocityEngine();
ExtendedProperties extendedProperties = new ExtendedProperties();
extendedProperties.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, TemplateTest.FILE_RESOURCE_LOADER_PATH);
velocityEngine.Init(extendedProperties);
VelocityContext context = new VelocityContext();
context.Put("yada", "line");
Template template = velocityEngine.GetTemplate(
GetFileName(null, "nv37", TemplateTest.TMPL_FILE_EXT));
StringWriter writer = new StringWriter();
#pragma warning disable 612,618
velocityEngine.MergeTemplate("nv37.vm", context, writer);
#pragma warning restore 612,618
//template.Merge(context, writer);
Console.WriteLine(writer);
}
示例9: CreateVelocityEngine
private VelocityEngine CreateVelocityEngine()
{
var velocity = new VelocityEngine();
var props = new ExtendedProperties();
props.SetProperty("file.resource.loader.path", _templateDirectory);
velocity.Init(props);
return velocity;
}
示例10: 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;
}
示例11: NVelocityTemplateRepository
public NVelocityTemplateRepository(string templateDirectory)
{
engine = new VelocityEngine();
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDirectory);
engine.Init(props);
}
示例12: CreateVelocityEngine
/// <inheritdoc />
public VelocityEngine CreateVelocityEngine()
{
var properties = new ExtendedProperties();
SetupVelocityEngine(properties);
var engine = new VelocityEngine(properties);
engine.Init();
return engine;
}
示例13: 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();
}
示例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: GetInitialisedEngine
private VelocityEngine GetInitialisedEngine()
{
VelocityEngine engine = new VelocityEngine();
ExtendedProperties properties = new ExtendedProperties();
properties.SetProperty(RuntimeConstants.RESOURCE_LOADER, "file");
properties.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, agencyService.CurrentAgency.TemplateDirectory);
engine.Init(properties);
return engine;
}