本文整理汇总了C#中Template.appendSection方法的典型用法代码示例。如果您正苦于以下问题:C# Template.appendSection方法的具体用法?C# Template.appendSection怎么用?C# Template.appendSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.appendSection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
static void Render()
{
Template tpl = new Template("default.tpl");
tpl.selectSection ("BLOGGER");
foreach (Blogger b in bloggers.Bloggers) {
tpl.setField ("BLOGGER_ERROR_MSG", b.Error ? error_msg : b.DateError ? date_error_msg : "");
tpl.setField ("BLOGGER_ERROR_IMG", b.Error || b.DateError ? error_img : "");
tpl.setField ("BLOGGER_URL", b.HtmlUrl.ToString ());
tpl.setField ("BLOGGER_NAME", b.Name);
tpl.setField ("BLOGGER_HEAD", ProcessHeadEntryAndReturnUrl (b.Head));
if (b.IrcNick != null)
tpl.setField ("BLOGGER_IRCNICK", b.IrcNick);
else
tpl.setField ("BLOGGER_IRCNICK", String.Empty);
tpl.setField ("BLOGGER_RSSURL", b.RssUrl);
tpl.appendSection ();
}
tpl.deselectSection ();
tpl.selectSection ("BLOG_DAY");
foreach (ArrayList day in GetDaysCollectionList ()) {
tpl.setField ("DAY_DATE", ((RssItem)day [0]).PubDate.Date.ToString ("M"));
tpl.selectSection ("DAY_ENTRY");
foreach (RssItem itm in day) {
tpl.setField ("ENTRY_LINK", itm.Link.ToString ());
Blogger bl = bloggers [itm.Author];
if (bl != null) {
tpl.setField ("ENTRY_PERSON", bl.Name);
if (bl.IrcNick != null)
tpl.setField ("ENTRY_PERSON_IRCNICK", "(" + bl.IrcNick + ")");
else
tpl.setField ("ENTRY_PERSON_IRCNICK", "");
tpl.setField ("ENTRY_PERSON_HEAD", ProcessHeadEntryAndReturnUrl (bl.Head));
tpl.setField ("ENTRY_PERSON_URL", bl.HtmlUrl.ToString());
} else {
throw new Exception ("No blogger for " + itm.Author + ".");
}
itm.Title = itm.Title.Substring (itm.Title.IndexOf (":")+2);
tpl.setField ("ENTRY_TITLE", itm.Title);
tpl.setField ("ENTRY_HTML", itm.Content ?? itm.Description);
tpl.setField ("ENTRY_DATE", itm.PubDate.ToString ("h:mm tt 'GMT'"));
tpl.appendSection ();
}
tpl.deselectSection ();
tpl.appendSection ();
}
tpl.deselectSection ();
TextWriter w = new StreamWriter (File.Create (outputFile));
w.Write (tpl.getContent ());
w.Flush ();
}
示例2: ProcessRequest
public void ProcessRequest(HttpContext context)
{
try {
appender.Clear();
log.Info("ProcessRequest started");
string[] validExtensions = new string[] { ".png", ".jpeg", ".jpg", ".gif" };
Uri url = context.Request.Url;
string urlOnlyString = url.GetLeftPart(UriPartial.Path);
string filePath = context.Server.MapPath(context.Server.UrlDecode(context.Request.Url.LocalPath));
string fileExtension = context.Request.Url.ToString(); fileExtension = fileExtension.Substring(fileExtension.LastIndexOf(".") +1).ToLower();
if (fileExtension.IndexOf("?") > -1) fileExtension = fileExtension.Substring(0,fileExtension.IndexOf("?"));
string directory = context.Server.MapPath(context.Server.UrlDecode(context.Request.Url.LocalPath));
string relativePath = HttpUtility.UrlDecode (context.Request.Path.Substring (context.Request.ApplicationPath.Length));
if (relativePath.StartsWith (Path.DirectorySeparatorChar.ToString ()) == false)
relativePath = Path.DirectorySeparatorChar.ToString () + relativePath;
string smallDir = "/bin/data/small_images";
// string web_themeDir = Util.CombinePath (context.Request.ApplicationPath, "bin/templates/") + GetSetting("template");
string web_cssFile = Util.CombinePath (context.Request.ApplicationPath, "bin/templates/") + GetSetting("template") + "/" + GetSetting("theme") + ".css";
string local_templateFile = Path.Combine (Path.Combine (context.Server.MapPath("/bin/templates/"), GetSetting("template")), "listing.tpl");
string local_binDir = Path.Combine(context.Request.PhysicalApplicationPath,"bin");
Template tpl = null;
if (context.Request.QueryString["GetSpecialImage"] != null) {
string special = context.Request.QueryString["GetSpecialImage"];
// TODO: I don't think this is very efficient:
//
log.Debug(System.Reflection.Assembly.GetExecutingAssembly ().FullName);
System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (special);
if (s != null) {
byte[] image = new byte[s.Length];
s.Read(image, 0, Convert.ToInt32(s.Length));
context.Response.ContentType = "image/" + special.Substring(special.IndexOf(".") +1);
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetExpires(DateTime.Now.AddDays(1));
context.Response.BinaryWrite (image);
context.Response.End();
s.Close();
image = null;
} else {
throw new Exception("Invalid special image: " + special);
}
return;
} else if (Directory.Exists(filePath)) {
// This is a directory
DirectoryInfo d = new DirectoryInfo(directory);
if (File.Exists(Path.Combine(d.FullName, ".nolisting")))
throw new HttpException(403, "You are not allowed to browse the requested directory. Please specify a filename instead.");
if (directory.StartsWith(local_binDir) == true | d.Name.StartsWith(".") == true & (d.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
throw new HttpException(403, "You are not allowed to access the requested directory.");
tpl = new Template(local_templateFile);
tpl.setField ("PAGE_TITLE", context.Request.Url.ToString());
tpl.setField ("PAGE_CSS", web_cssFile);
int dirCount = 0;
int fileCount = 0;
// Show Folders
tpl.selectSection("DIR_ITEM");
foreach (DirectoryInfo subDir in d.GetDirectories()) {
if (subDir.FullName.StartsWith(local_binDir) == false & subDir.Name.StartsWith(".") == false & (subDir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) {
dirCount += 1;
tpl.setField("DIR_URL", context.Request.Url.ToString() + subDir.Name);
tpl.setField("DIR_NAME", subDir.Name);
tpl.appendSection();
}
}
tpl.deselectSection();
tpl.setField("PAGE_DIRCOUNT", dirCount);
if (d.GetDirectories().Length > 0 & d.GetFiles().Length > 0) {
tpl.selectSection("LISTS_SEPORATOR");
tpl.appendSection();
tpl.deselectSection();
//.........这里部分代码省略.........