本文整理汇总了C#中ITemplate类的典型用法代码示例。如果您正苦于以下问题:C# ITemplate类的具体用法?C# ITemplate怎么用?C# ITemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITemplate类属于命名空间,在下文中一共展示了ITemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:31,代码来源:GenericElementProcessor.Shared.cs
示例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);
};
}
开发者ID:nickbabcock,项目名称:EU4.Savegame,代码行数:27,代码来源:StatsModule.cs
示例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;
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:7,代码来源:CodeUntypedMarkupParser.Shared.cs
示例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());
}
开发者ID:i4004,项目名称:Simplify.Web,代码行数:12,代码来源:DataCollector.cs
示例5: TemplateOveridingDefinitionTile
public TemplateOveridingDefinitionTile(string name, ITemplate template, ITile extends,
IEnumerable<TileAttribute> attributes)
: base(name, template, attributes)
{
_extends = extends;
Attributes.MergeTileLazy(_extends);
}
开发者ID:rslijp,项目名称:sharptiles,代码行数:7,代码来源:TemplateOveridingDefinitionTile.cs
示例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);
}
开发者ID:marianoir,项目名称:ebuyplacenet,代码行数:32,代码来源:EbuyPopup.ascx.cs
示例7: DocumentParser
public DocumentParser(ITemplate template)
{
Ensure.ArgumentNotNull(template, "template");
_template = template;
_markdown = new Markdown();
}
开发者ID:ryanwentzel,项目名称:Proverb,代码行数:7,代码来源:DocumentParser.cs
示例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; });
}
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:28,代码来源:IntMarkupParser.Shared.cs
示例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;
}
开发者ID:JohannesOstensjo,项目名称:EPiUtilities,代码行数:14,代码来源:TemplatedPageDataItemListControlBase.cs
示例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;
}
开发者ID:i4004,项目名称:Simplify.Web,代码行数:12,代码来源:Tpl.cs
示例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());
}
}
开发者ID:jyunfan2015,项目名称:forge,代码行数:7,代码来源:RuntimeEntity.cs
示例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; });
}
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:30,代码来源:PositionMarkupParser.Shared.cs
示例13: Render
public void Render(ITemplate tpl, IInstantiatedTemplateControl ctl, StringBuilder sb) {
if (IsCData)
sb.Append("<![CDATA[");
sb.Append(Text);
if (IsCData)
sb.Append("]]>");
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:7,代码来源:LiteralFragment.Shared.cs
示例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;
}
开发者ID:i2e-haw-hamburg,项目名称:gesture-recognition,代码行数:7,代码来源:ThreeDGestureRecognizer.cs
示例15: AddTemplate
protected void AddTemplate(ITemplate template) {
if (template != null) {
TemplateItem i = new TemplateItem();
template.InstantiateIn(i);
Controls.Add(i);
}
}
开发者ID:cmarfia,项目名称:KalikoCMS.Core,代码行数:7,代码来源:BaseList.cs
示例16: TryGet
public static bool TryGet(string name, out ITemplate template)
{
if (name == null)
throw new ArgumentNullException ("name");
return templates.TryGetValue (name, out template);
}
开发者ID:imintsystems,项目名称:Waser,代码行数:7,代码来源:Factory.cs
示例17: TryProcess
public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
if (node.NodeType != XmlNodeType.ProcessingInstruction || node.Name != "view")
return false;
if (!isRoot)
throw ParserUtils.TemplateErrorException(string.Format("The view directive can only appear outside of the template.", node.Name));
string[] serverTypeArr = Utils.RegexExec(node.Value, "modelType=\"([^\"]*)\"", "");
string[] clientTypeArr = Utils.RegexExec(node.Value, "clientModelType=\"([^\"]*)\"", "");
if (serverTypeArr == null && clientTypeArr != null)
throw ParserUtils.TemplateErrorException("You cannot specify a client type for the model if you don't specify a server type");
if (template.HasMember("Model") || template.HasMember("model") || template.HasMember("Saltarelle.Mvc.IView.Model"))
throw ParserUtils.TemplateErrorException("The template already defines at least one of the members essential to use the view directive. Have you specified <?view?> more than once?");
string serverType = (serverTypeArr != null ? serverTypeArr[1] : "object"), clientType = (clientTypeArr != null ? clientTypeArr[1] : null);
string viewInterface = "Saltarelle.Mvc.IView<" + serverType + ">";
if (template.ImplementsServerInterface(viewInterface))
throw ParserUtils.TemplateErrorException("The template already implements the interface " + viewInterface + ".");
template.AddServerInterface(viewInterface);
template.AddMember(new FieldMember("model", serverType, clientType));
template.AddMember(new PropertyMember("Model", serverType, null, AccessModifier._Public, "model", serverType, null, true, true, "ModelChanged", false));
template.AddMember(new PropertyMember("Saltarelle.Mvc.IView.Model", "object", null, AccessModifier._None, "model", serverType, null, true, true, "ModelChanged", false));
return true;
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:27,代码来源:ViewDirectiveNodeProcessor.Shared.cs
示例18: ActualProcess
private void ActualProcess(XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
foreach (INodeProcessor p in processors) {
if (p.TryProcess(this, node, isRoot, template, currentRenderFunction))
return;
}
throw ParserUtils.TemplateErrorException("The node " + node.ToString() + " could not be handled.");
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:7,代码来源:DocumentProcessor.Shared.cs
示例19: ProcessRecursive
public void ProcessRecursive(XmlNode node, ITemplate template, IRenderFunction currentRenderFunction) {
if (template == null) throw Utils.ArgumentException("template");
if (currentRenderFunction == null) throw Utils.ArgumentException("currentRenderFunction");
if (node == null) throw Utils.ArgumentNullException("node");
ActualProcess(node, false, template, currentRenderFunction);
}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:7,代码来源:DocumentProcessor.Shared.cs
示例20: InstantiateTemplate
public void InstantiateTemplate (ITemplate template)
{
if (!renderOuterTable)
template.InstantiateIn (this);
else
template.InstantiateIn (_containerCell);
}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:Login.cs
注:本文中的ITemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论