本文整理汇总了C#中ITemplate类的典型用法代码示例。如果您正苦于以下问题:C# ITemplate类的具体用法?C# ITemplate怎么用?C# ITemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITemplate类属于命名空间,在下文中一共展示了ITemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryProcess
public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
if (node.NodeType != XmlNodeType.Element)
return false;
GenericElementProcessorContext context = new GenericElementProcessorContext();
currentRenderFunction.AddFragment(new LiteralFragment("<" + node.Name));
AddAttributeFragments(docProcessor, node, isRoot, template, currentRenderFunction, context);
if (context.Id != null) {
string tagName = node.Name;
if (tagName.ToLowerCase() == "input" && context.Type != null)
tagName += "/" + context.Type;
template.AddMember(new NamedElementMember(tagName, context.Id));
}
if (noContentTags.Contains(node.Name)) {
if (Utils.GetNumChildNodes(node) > 0)
throw ParserUtils.TemplateErrorException("The tag " + node.Name + " can not have children.");
currentRenderFunction.AddFragment(new LiteralFragment("/>"));
}
else {
currentRenderFunction.AddFragment(new LiteralFragment(">"));
Utils.DoForEachChild(node, delegate(XmlNode child) {
docProcessor.ProcessRecursive(child, template, currentRenderFunction);
});
currentRenderFunction.AddFragment(new LiteralFragment("</" + node.Name + ">"));
}
return true;
}
示例2: StatsModule
public StatsModule(ITemplate tmpl, IIdGenerator idgen, SavegameStorage storage)
{
Post["/games"] = _ =>
{
// Get the temporary location of the file on the server
var file = Request.Headers["X-FILE"].FirstOrDefault();
// Get the extension of the file when it was uploaded as the
// temporary file doesn't have an extension
var extension = Request.Headers["X-FILE-EXTENSION"].FirstOrDefault();
if (file == null)
throw new ArgumentException("File can't be null");
if (extension == null)
throw new ArgumentException("File extension can't be null");
Save savegame;
using (var stream = getStream(file, extension))
using (parsingTimer.NewContext())
savegame = new Save(stream);
// Turn the savegame into html and return the url for it
var stats = statsTimer.Time(() => Aggregate(savegame));
string contents = templateTimer.Time(() => tmpl.Render(stats));
string id = idgen.NextId();
return storage.Store(contents, id);
};
}
示例3: TryParse
public IFragment TryParse(string markup, ITemplate template) {
if (markup.StartsWith("code:"))
return new CodeExpressionFragment(Utils.Substring(markup, 5, markup.Length - 5).Trim());
else if (markup.StartsWith("{=") && markup.EndsWith("}"))
return new CodeExpressionFragment(Utils.Substring(markup, 2, markup.Length - 3).Trim());
return null;
}
示例4: Add
/// <summary>
/// Set template variable value with data from template (all occurrences will be replaced)
/// </summary>
/// <param name="variableName">Variable name in master template file</param>
/// <param name="template">The template.</param>
public void Add(string variableName, ITemplate template)
{
if (template == null)
return;
Add(variableName, template.Get());
}
示例5: TemplateOveridingDefinitionTile
public TemplateOveridingDefinitionTile(string name, ITemplate template, ITile extends,
IEnumerable<TileAttribute> attributes)
: base(name, template, attributes)
{
_extends = extends;
Attributes.MergeTileLazy(_extends);
}
示例6: AddTemplateAsControl
private void AddTemplateAsControl(ITemplate anyTemplate, object cuurentItem)
{
javascript.Visible = false;
templateContentHolder = new EbuyPopupContenido(cuurentItem);
MensajePopUp.Text = Titulo;
if (BotonCancelar)
Cancelar.Visible = true;
else
Cancelar.Visible = false;
if (BotonAceptar)
{
Aceptar.Visible = true;
if (BotonAceptarDesapareceAlApretar)
{
javascript.Visible = true;
Literal1.Text = this.ID;
Aceptar.OnClientClick += "javascript:BotonAceptarDesaparece"+this.ID+"();";
}
}
else
Aceptar.Visible = false;
if (BotonOK)
OK.Visible = true;
else
OK.Visible = false;
Aceptar.Click += AceptarOnClick;
anyTemplate.InstantiateIn(templateContentHolder);
PanelContenedor.Controls.Add(templateContentHolder);
// this.Controls.Add(PanelContenedor);
}
示例7: DocumentParser
public DocumentParser(ITemplate template)
{
Ensure.ArgumentNotNull(template, "template");
_template = template;
_markdown = new Markdown();
}
示例8: Parse
public TypedMarkupData Parse(string registeredPrefix, bool isArray, string value, ITemplate template) {
if (isArray) {
StringBuilder sb = new StringBuilder();
sb.Append("new int[] {");
int[] ints;
if (value.Trim() != "") {
string[] split = value.Split('|');
ints = new int[split.Length];
for (int i = 0; i < split.Length; i++) {
if (Utils.RegexExec(split[i], Utils.IntRegex, "") == null)
throw ParserUtils.TemplateErrorException(ParserUtils.MakeTypedMarkupErrorMessage(registeredPrefix, isArray, value));
sb.Append(i > 0 ? ", " : " ");
ints[i] = Utils.ParseInt(split[i]);
sb.Append(Utils.ToStringInvariantInt(ints[i]));
}
}
else
ints = new int[0];
sb.Append(" }");
return new TypedMarkupData(sb.ToString(), delegate() { return ints; });
}
else {
if (Utils.RegexExec(value, Utils.IntRegex, "") == null)
throw ParserUtils.TemplateErrorException(ParserUtils.MakeTypedMarkupErrorMessage(registeredPrefix, isArray, value));
int i = Utils.ParseInt(value);
return new TypedMarkupData(Utils.ToStringInvariantInt(i), delegate() { return i; });
}
}
示例9: AddItemTemplate
/// <summary>
/// Adds an item with the specified template.
/// </summary>
/// <param name="template"></param>
/// <param name="item"></param>
/// <param name="itemNumber"></param>
/// <param name="selected"></param>
protected void AddItemTemplate(ITemplate template, PageData item, int itemNumber, bool selected)
{
if (AddSeparator)
AddSeparatorTemplate();
AddTemplate(new PageDataItemTemplateContainer(item, itemNumber, selected), template);
Added = true;
}
示例10: Tpl
/// <summary>
/// Initializes a new instance of the <see cref="Tpl" /> class.
/// </summary>
/// <param name="template">The template.</param>
/// <param name="title">The site title.</param>
public Tpl(ITemplate template, string title)
{
if (template != null)
Data = template.Get();
Title = title;
}
示例11: RuntimeEntity
public RuntimeEntity(int uniqueId, ITemplate template, IEventDispatcher eventDispatcher)
: this(uniqueId, eventDispatcher, "") {
foreach (DataAccessor accessor in template.SelectData()) {
Data.IData data = template.Current(accessor);
AddData_unlocked(accessor, data.Duplicate());
}
}
示例12: Parse
public TypedMarkupData Parse(string registeredPrefix, bool isArray, string value, ITemplate template) {
if (isArray) {
StringBuilder sb = new StringBuilder();
sb.Append("new Position[] {");
Position[] positions;
if (value.Trim() != "") {
string[] split = value.Split('|');
positions = new Position[split.Length];
for (int i = 0; i < split.Length; i++) {
StringPositionPair v = ParseSingle(split[i]);
if (v == null)
throw ParserUtils.TemplateErrorException(ParserUtils.MakeTypedMarkupErrorMessage(registeredPrefix, isArray, value));
sb.Append(i > 0 ? ", " : " ");
positions[i] = v.p;
sb.Append(v.s);
}
}
else
positions = new Position[0];
sb.Append(" }");
return new TypedMarkupData(sb.ToString(), delegate() { return positions; });
}
else {
StringPositionPair v = ParseSingle(value);
if (v == null)
throw ParserUtils.TemplateErrorException(ParserUtils.MakeTypedMarkupErrorMessage(registeredPrefix, isArray, value));
return new TypedMarkupData(v.s, delegate { return v.p; });
}
}
示例13: Render
public void Render(ITemplate tpl, IInstantiatedTemplateControl ctl, StringBuilder sb) {
if (IsCData)
sb.Append("<![CDATA[");
sb.Append(Text);
if (IsCData)
sb.Append("]]>");
}
示例14: ProbabilityCalculation
public static double ProbabilityCalculation(ITemplate template, IDictionary<JointType, InputVector> input)
{
var end = template.EndCondition(input);
var start = template.StartCondition(input);
var motion = template.MotionCharacteristic(input);
return end*start*motion;
}
示例15: AddTemplate
protected void AddTemplate(ITemplate template) {
if (template != null) {
TemplateItem i = new TemplateItem();
template.InstantiateIn(i);
Controls.Add(i);
}
}