/// <summary> /// 栏目的绑定模板列表保存到地图文件 /// </summary> /// <param name="cg">栏目的绑定模板</param> /// <param name="channelUrl">栏目URL</param> /// <param name="file">文件</param> public static void SaveToTemplateMapFile(ChannelTemplateGroup cg, string channelUrl, string file) { ArrayList myMaps = new ArrayList(); LoadMaps(file, myMaps); if (!channelUrl.EndsWith("/")) { channelUrl += "/"; } myMaps = RemoveMap(myMaps, channelUrl); MapItem map = new MapItem(); if (!string.IsNullOrEmpty(cg.IndexTemplate)) { string url = channelUrl; if (cg.IndexInherit) { url += "*/"; } myMaps.Add(new MapItem(url, cg.IndexTemplate)); } if (!string.IsNullOrEmpty(cg.ListTemplate)) { string url = channelUrl; if (cg.ListInherit) { url += "*/"; } url = url + "list"; myMaps.Add(new MapItem(url, cg.ListTemplate)); } if (!string.IsNullOrEmpty(cg.DetailTemplate)) { string url = channelUrl; if (cg.DetailInherit) { url += "*/"; } url = url + "detail"; myMaps.Add(new MapItem(url, cg.DetailTemplate)); } if (!string.IsNullOrEmpty(cg.SearchTemplate)) { string url = channelUrl; if (cg.SearchInherit) { url += "*/"; } url = url + "search"; myMaps.Add(new MapItem(url, cg.SearchTemplate)); } SaveToMapFile(myMaps, file); }
/// <summary> /// 根据栏目URL获取对应的所有栏目绑定模板列表 /// </summary> /// <param name="channelUrl">栏目Url</param> /// <returns>栏目绑定模板</returns> public ChannelTemplateGroup GetChannelTemplate(string channelUrl) { if (!channelUrl.EndsWith("/")) { channelUrl += "/"; } ChannelTemplateGroup ctg = new ChannelTemplateGroup(); foreach (MapItem mi in Maps) { if (mi.Url == channelUrl || mi.Url == channelUrl + "*/") { ctg.IndexTemplate = mi.Template; } if (mi.Url == channelUrl + "*/") { ctg.IndexInherit = true; } if (mi.Url == channelUrl + "*/list" || mi.Url == channelUrl + "list") { ctg.ListTemplate = mi.Template; } if (mi.Url == channelUrl + "*/list") { ctg.ListInherit = true; } if (mi.Url == channelUrl + "*/detail" || mi.Url == channelUrl + "detail") { ctg.DetailTemplate = mi.Template; } if (mi.Url == channelUrl + "*/detail") { ctg.DetailInherit = true; } if (mi.Url == channelUrl + "*/search" || mi.Url == channelUrl + "search") { ctg.SearchTemplate = mi.Template; } if (mi.Url == channelUrl + "*/search") { ctg.SearchInherit = true; } } return(ctg); }