/// <summary> /// The build node name. /// </summary> /// <param name="item"> /// The item. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> private static string BuildNodeName(Item item) { if (item == null) { return(string.Empty); } var templateId = item.TemplateID.ToString(); switch (templateId) { case ItemToItem.TemplateId: var itemToItem = new ItemToItem(item); return(BuildItemToItemNodeName(itemToItem)); case SectionToItem.TemplateId: var sectionToItem = new SectionToItem(item); return(BuildSectionToItemNode(sectionToItem)); case SectionToSection.TemplateId: var sectionToSection = new SectionToSection(item); return(BuildSectionToSectionNode(sectionToSection)); case RegExRedirect.TemplateId: var regExRedirect = new RegExRedirect(item); return(BuildRegExNodeName(regExRedirect)); } return(string.Format("<p>{0}</p>", item.Name)); }
/// <summary> /// Builds the name of the regex node. /// </summary> /// <param name="item">The item.</param> /// <returns>regex node</returns> private static string BuildRegExNodeName(RegExRedirect item) { if (item == null) { return(string.Empty); } return(string.Format( "<div class=\"block-name\"><div class=\"name\">{0}</div><div class=\"title\">Expression: {2}, Value: {3}</div></div><div class=\"description\">Redirect Code: {4}, Last Use: {5}, ID: {1}</div>", item.Name, item.ID, !string.IsNullOrEmpty(item.Expression.Value) ? item.Expression.Value : "Empty", !string.IsNullOrEmpty(item.Value.Value) ? item.Value.Value : "Empty", item.RedirectCode != 0 ? item.RedirectCode : Configuration.RedirectStatusCode, item.LastUse.DateTime.ToString("MM/dd/yy") != "01/01/01" ? item.LastUse.DateTime.ToString("MM/dd/yy") : "Never")); }
/// <summary> /// Adds the regex redirect. /// </summary> /// <param name="item">The item.</param> /// <returns>redirect item</returns> private static RegExItem AddRegExRedirect(Item item) { if (item == null) { return null; } var regExRedirect = new RegExRedirect(item); if (string.IsNullOrEmpty(regExRedirect.Expression.Value) || string.IsNullOrEmpty(regExRedirect.Value.Value)) { return null; } var redirectItem = new RegExItem { ItemId = regExRedirect.ID, Value = new Regex(regExRedirect.Value.Value, RegexOptions.IgnoreCase), Expression = new Regex(regExRedirect.Expression.Value, RegexOptions.IgnoreCase), RedirectCode = regExRedirect.RedirectCode }; return redirectItem; }