本文整理汇总了C#中StringTemplate.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# StringTemplate.Reset方法的具体用法?C# StringTemplate.Reset怎么用?C# StringTemplate.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTemplate
的用法示例。
在下文中一共展示了StringTemplate.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public static string Generate(string input, Dictionary<string, object> data)
{
var template = new StringTemplate(input);
foreach (var d in data)
template.SetAttribute(d.Key, d.Value);
string result = template.ToString();
;
template.Reset();
data.Clear();
template = null;
return result;
}
示例2: ProcessMubbleRequest
public override void ProcessMubbleRequest(System.Web.HttpContext context)
{
string slug = this.Url.GetPathItem(1);
if (slug == null || slug.Length == 0) slug = "";
Mubble.Models.RssFeed feed = null;
foreach (RssFeed f in this.Controller.RssFeeds)
{
if (f.Slug.Equals(slug, StringComparison.CurrentCultureIgnoreCase))
{
feed = f;
break;
}
}
if (feed != null)
{
if (feed.RedirectUrl != null && feed.RedirectUrl.Length > 0)
{
bool matches = false;
if (feed.RedirectExceptions.Length > 0 && context.Request.UserAgent != null && context.Request.UserAgent.Length > 0)
{
string[] tests = feed.RedirectExceptions.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (string test in tests)
{
if (context.Request.UserAgent.Contains(test))
{
matches = true;
break;
}
}
}
if (!matches)
{
context.Response.Redirect(feed.RedirectUrl);
}
}
XmlDocument doc = new XmlDocument();
doc.LoadXml(
@"<?xml version=""1.0"" encoding=""utf-8""?>
<rss version=""2.0"">
</rss>");
XmlNode channel = this.AppendChild(doc.SelectSingleNode("rss"), "channel", "");
if (feed.Title != null && feed.Title.Length > 0)
{
this.AppendChild(channel, "title", feed.Title);
}
else
{
this.AppendChild(channel, "title", this.Controller.Title);
}
if (feed.Link != null && feed.Link.Length > 0)
{
this.AppendChild(channel, "link", feed.Link);
}
else
{
this.AppendChild(channel, "link", this.Url.ToString("HtmlHandler", ""));
}
if (feed.Description != null && feed.Description.Length > 0)
{
this.AppendChild(channel, "description", feed.Description);
}
else
{
this.AppendChild(channel, "description", this.Controller.Excerpt);
}
StringTemplate t = new StringTemplate(
feed.ItemFormat != null && feed.ItemFormat.Length > 0 ? feed.ItemFormat : "<p>$item.Excerpt$</p><p><a href=\"$link$\">Read More...</a></p>"
);
foreach (IRssItem i in this.Controller.GetRssItems(Security.User.GetRoles()))
{
t.Reset();
XmlNode item = this.AppendChild(channel, "item", "");
string url = MubbleUrl.Create(i.Url.Path, i.Url.Extra).ToString("HtmlHandler");
t.SetAttribute("link", url);
t.SetAttribute("item", i);
t.SetAttribute("guid", url);
t.SetAttribute("escaped.{Url, Title, Excerpt}",
System.Web.HttpUtility.UrlEncode(url),
System.Web.HttpUtility.UrlEncode(i.Title),
System.Web.HttpUtility.UrlEncode(i.Excerpt)
);
this.AppendChild(item, "title", i.Title);
this.AppendChild(item, "link", url);
this.AppendChild(item, "guid", url);
this.AppendChild(item, "pubDate", i.PublishDate.ToUniversalTime().ToString("R"));
foreach (string a in i.Authors)
{
Author author = Author.FindFirst(a);
//.........这里部分代码省略.........