public void GivenInternalLink_WhenGetValueWithUseAbsoluteUrlsSetToFalse_ThenReturnsCorrectRelativeLink() { var value = "random-internallink"; var linkItemCollection = new LinkItemCollection(); var expected = "/my-pretty-url/?anyQuery=hej"; var settings = new UrlSettings { UseAbsoluteUrls = false }; this._urlHelper.ContentUrl(Arg.Any <Url>(), settings) .Returns(expected); var linkItem = Substitute.For <EPiServer.SpecializedProperties.LinkItem>(); linkItem.Href.Returns(value); linkItem.Text.Returns("any text"); linkItem.Title.Returns("any title"); linkItem.Target.Returns("_blank"); linkItem.ReferencedPermanentLinkIds.Returns(new List <Guid> { Guid.NewGuid() }); linkItemCollection.Add(linkItem); var result = ((IEnumerable <LinkItem>) this._sut.GetValue(linkItemCollection, settings)).ToList(); result.Count.ShouldBe(1); result.ShouldContain(x => x.Href == expected); result.ShouldContain(x => x.Text == "any text"); result.ShouldContain(x => x.Title == "any title"); result.ShouldContain(x => x.Target == "_blank"); }
public static LinkItemCollection GetPropertyValue <TContentItem>(this TContentItem contentItem, Expression <Func <TContentItem, LinkItemCollection> > expression) where TContentItem : ContentItem { MemberExpression memberExpression = GetMemberExpression(expression); return(LinkItemCollection.FindByPageAndPropertyName(contentItem, memberExpression.Member.Name)); }
public void GivenInternalLink_WhenHandle_ThenReturnsCorrectAbsoluteLink() { var value = "random-internallink"; var linkItemCollection = new LinkItemCollection(); var expected = "https://example.com/my-pretty-url/?anyQuery=hej"; this._urlHelper.ContentUrl(Arg.Any <Url>(), Arg.Any <UrlSettings>()) .Returns(expected); var linkItem = Substitute.For <EPiServer.SpecializedProperties.LinkItem>(); linkItem.Href.Returns(value); linkItem.Text.Returns("any text"); linkItem.Title.Returns("any title"); linkItem.Target.Returns("_blank"); linkItem.ReferencedPermanentLinkIds.Returns(new List <Guid> { Guid.NewGuid() }); linkItemCollection.Add(linkItem); var result = ((IEnumerable <LinkItem>) this._sut.Handle(linkItemCollection, null, null)).ToList(); result.Count.ShouldBe(1); result.ShouldContain(x => x.Href == expected); result.ShouldContain(x => x.Text == "any text"); result.ShouldContain(x => x.Title == "any title"); result.ShouldContain(x => x.Target == "_blank"); }
public IEnumerable <GroLinkItem> PopulateLinkItems(LinkItemCollection linkCollection, HttpContextBase httpContext) { var result = new List <GroLinkItem>(); if (linkCollection == null) { return(result); } foreach (var item in linkCollection) { var linkItem = GroLinkItem.FromLinkItem(item); if (linkItem.Type != GroLinkType.InternalLink) { result.Add(linkItem); continue; } var content = item.GetContent(); if (content is PageData && !PageAccess.CanAccessPage(_usersManagementService, _orgUserRepo, (PageData)content, httpContext)) { continue; } result.Add(linkItem); } return(result); }
/// <summary> /// Retrieveing documents list from remote location /// </summary> /// <param name="externalURL"></param> public static LinkItemCollection GetExternalLinks(string externalURL) { ExternalDocStub externalLinksObj = new Helpers.ExternalDocStub(); using (StreamReader sr = new StreamReader(HostingEnvironment.MapPath(externalURL))) { externalLinksObj = JsonConvert.DeserializeObject <ExternalDocStub>(sr.ReadToEnd()); } List <LinkItem> listItem = new List <LinkItem>(); foreach (var asset in externalLinksObj.Assets) { LinkItem lnkItem = new LinkItem(); lnkItem.Title = asset.Title; lnkItem.Text = asset.PreviewURL; lnkItem.Href = asset.URL; listItem.Add(lnkItem); } LinkItemCollection itemCollection = new LinkItemCollection(listItem); return(itemCollection); }
public static List <PageData> ToPages(this LinkItemCollection linkItemCollection) { var pages = new List <PageData>(); //TODO: Va? ska det verkligen vara såhär? foreach (var linkItem in linkItemCollection) { var permanentLink = linkItem.ToPermanentLink(); if (permanentLink.Contains("~/link") && permanentLink.Contains(".aspx")) { var link = permanentLink.Substring(permanentLink.IndexOf("~/link", StringComparison.Ordinal) + 7); var indexOfAspx = link.IndexOf(".aspx", StringComparison.Ordinal); if (indexOfAspx != -1) { var substring = link.Substring(0, indexOfAspx); var guid = Guid.Parse(substring); var pageData = ServiceLocator.Current.GetInstance <IContentRepository>().Get <PageData>(guid); pages.Add(pageData); } } } return(pages); }
public LinkItemCollection FilterB2BNavigationForCurrentUser(LinkItemCollection b2BLinks) { var filteredLinks = new LinkItemCollection(); var currentContact = _customerService.GetCurrentContact(); foreach (var link in b2BLinks) { switch (currentContact.B2BUserRole) { case B2BUserRoles.Admin: if (Constant.B2BNavigationRoles.Admin.Contains(link.Text)) { filteredLinks.Add(link); } break; case B2BUserRoles.Approver: if (Constant.B2BNavigationRoles.Approver.Contains(link.Text)) { filteredLinks.Add(link); } break; } } return(filteredLinks); }
public virtual object GetTaskTraceInfo(HttpContext context) { YZRequest request = new YZRequest(context); int taskid = request.GetInt32("TaskID"); BPMTask task; NodeItemCollection nodes = new NodeItemCollection(); LinkItemCollection links = new LinkItemCollection(); BPMStepCollection steps = new BPMStepCollection(); //获得数据 using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); task = BPMTask.Load(cn, taskid); BPMProcess.GetTaskTraceInfo(cn, task.ProcessName, task.ProcessVersion, out nodes, out links); steps = BPMTask.GetAllSteps(cn, taskid); } return(new { Task = this.SerializeTask(task), Process = new { Nodes = nodes, Links = links }, Steps = this.SerializeSteps(steps) }); }
public static void SetPropertyValue <TContentItem>(this TContentItem contentItem, Expression <Func <TContentItem, object> > expression, object value) where TContentItem : ContentItem { MemberExpression memberExpression = null; if (expression.Body is MemberExpression) { memberExpression = (MemberExpression)expression.Body; } else if (expression.Body is UnaryExpression) { memberExpression = ((UnaryExpression)expression.Body).Operand as MemberExpression; } if (memberExpression == null) { throw new Exception("The body of the expression must be either a MemberExpression or a UnaryExpression."); } if (value is LinkItemCollection) { //LinkItemCollection needs to be saved as a json string LinkItemCollection links = value as LinkItemCollection; contentItem.SetDetail(memberExpression.Member.Name, links.ToJSONString(), typeof(string)); } else { contentItem.SetDetail(memberExpression.Member.Name, value, ((PropertyInfo)memberExpression.Member).PropertyType); } }
protected virtual void AddMyAccountMenu(CommerceHomePage homePage, CommerceHeaderViewModel viewModel) { if (HttpContext.Current != null && !HttpContext.Current.Request.IsAuthenticated) { viewModel.UserLinks = new LinkItemCollection(); return; } var menuItems = new LinkItemCollection(); var filter = new FilterContentForVisitor(); var contact = _customerService.GetCurrentContact(); if (contact != null && contact.FoundationOrganization != null) { var orgLink = new LinkItem { Href = _urlResolver.GetUrl(homePage.OrganizationMainPage), Text = _localizationService.GetString("My Organization", "My Organization"), Title = _localizationService.GetString("My Organization", "My Organization") }; //orgLink.Attributes.Add("css", "fa-sign-out"); menuItems.Add(orgLink); } foreach (var linkItem in homePage.MyAccountCommerceMenu ?? new LinkItemCollection()) { if (!UrlResolver.Current.TryToPermanent(linkItem.Href, out var linkUrl)) { continue; } if (linkUrl.IsNullOrEmpty()) { continue; } var urlBuilder = new UrlBuilder(linkUrl); var content = _urlResolver.Route(urlBuilder); if (content == null || filter.ShouldFilter(content)) { continue; } linkItem.Title = linkItem.Text; menuItems.Add(linkItem); } var signoutText = _localizationService.GetString("/Header/Account/SignOut", "Sign Out"); var link = new LinkItem { Href = "/publicapi/signout", Text = signoutText, Title = signoutText }; link.Attributes.Add("css", "fa-sign-out"); menuItems.Add(link); viewModel.UserLinks.AddRange(menuItems); }
/// <summary> /// Default constructor /// </summary> public LinksPageViewModel() { // Create the collections LocalLinkItems = new LinkItemCollection(); CommunityLinkItems = new LinkItemCollection(); ForumLinkItems = new LinkItemCollection(); ToolsLinkItems = new LinkItemCollection(); // Enable collection synchronization BindingOperations.EnableCollectionSynchronization(LocalLinkItems, this); BindingOperations.EnableCollectionSynchronization(CommunityLinkItems, this); BindingOperations.EnableCollectionSynchronization(ForumLinkItems, this); BindingOperations.EnableCollectionSynchronization(ToolsLinkItems, this); // Create commands RefreshCommand = new AsyncRelayCommand(async() => await Task.Run(async() => await RefreshAsync())); // Create properties AsyncLock = new AsyncLock(); // Refresh on startup Metro.App.Current.StartupComplete += async(s, e) => await RefreshAsync(); Services.Data.CultureChanged += async(s, e) => await Task.Run(async() => await RefreshAsync()); Services.Data.UserLevelChanged += async(s, e) => await Task.Run(async() => await RefreshAsync()); }
public static IEnumerable <T> ToContentItems <T>(this LinkItemCollection links, IContentRepository repo) where T : ContentData { if (links == null) { yield break; } foreach (var link in links) { var linkUrl = new UrlBuilder(link.Href); if (!PermanentLinkMapStore.ToMapped(linkUrl)) { continue; } var contentLink = PermanentLinkUtility.GetContentReference(linkUrl); var item = repo.Get <T>(contentLink); if (item != null) { yield return(item); } } }
private void LoadEntity(string entityName, SiteMapNode parentNode) { LinkItemCollection items = LinkItemCollection.GetAllFirstLevel(entityName, AppLogic.AppConfigNativeInt("MaxMenuSize"), ThisCustomer.LocaleSetting); if (items != null) { ExtractEntity(items, parentNode, 1); } }
public List <PageData> Load(LinkItemCollection links) { if (links == null || links.Count == 0) { return(ServiceLocator.Current.GetInstance <IContentRepository>().GetChildren <PageData>(ContentReference.StartPage).ToList()); } MainMenuLinks = links.ToPages(); return(MainMenuLinks); }
/// <summary> /// Converts a LinkItemCollection to typed pages. Any non-pages will be filtered out. (Not compatible with PageList - Use ToPageDataList) /// </summary> /// <typeparam name="T">PageType</typeparam> /// <param name="linkItemCollection">The collection of links to convert</param> /// <returns>An enumerable of typed PageData</returns> public static IEnumerable <T> ToPages <T>(this LinkItemCollection linkItemCollection) where T : PageData { foreach (PageData page in ToContent <PageData>(linkItemCollection)) { if (IsPageAccessible(page)) { yield return((T)page); } } }
private static void GetItems(string type, LinkItemCollection collection, ref List <IListItem> itemList) { Type listType; if (IgnobilisService.Instance.Settings.Functionality.ContentLists.TryGetValue(type, out listType)) { var instance = (IList)Activator.CreateInstance(listType); instance.Init(collection); itemList.AddRange(instance.Items); } }
public bool Init(LinkItemCollection linkCollection) { var pdList = linkCollection.ToPages(); var enumerable = FilterForVisitor.Filter(pdList); foreach (var child in enumerable) { Items.Add(new PageDataItem((PageData)child)); } return(Items.Count != 0); }
public virtual void AddMyAccountMenu <THomePage, THeaderViewModel>(THomePage homePage, THeaderViewModel viewModel) where THeaderViewModel : HeaderViewModel, new() where THomePage : CmsHomePage { if (HttpContext.Current != null && !HttpContext.Current.Request.IsAuthenticated) { viewModel.UserLinks = new LinkItemCollection(); return; } var menuItems = new LinkItemCollection(); var filter = new FilterContentForVisitor(); foreach (var linkItem in homePage.MyAccountCmsMenu ?? new LinkItemCollection()) { if (!UrlResolver.Current.TryToPermanent(linkItem.Href, out var linkUrl)) { continue; } if (linkUrl.IsNullOrEmpty()) { continue; } var urlBuilder = new UrlBuilder(linkUrl); var content = _urlResolver.Route(urlBuilder); if (content == null || filter.ShouldFilter(content)) { continue; } linkItem.Title = linkItem.Text; menuItems.Add(linkItem); } var signoutText = _localizationService.GetString("/Header/Account/SignOut", "Sign Out"); var link = new LinkItem { Href = "/publicapi/signout", Text = signoutText, Title = signoutText }; link.Attributes.Add("css", "fa-sign-out"); menuItems.Add(link); viewModel.UserLinks.AddRange(menuItems); }
/// <summary> /// Prepares all links in a LinkItemCollection for output /// by filtering out inaccessible links and ensures all links are correct. /// </summary> /// <param name="linkItemCollection">The collection of links to prepare.</param> /// <param name="targetExternalLinksToNewWindow">True will set target to _blank if target is not specified for the LinkItem.</param> /// <returns>A prepared and filtered list of LinkItems</returns> public static IEnumerable <LinkItem> ToPreparedLinkItems(this LinkItemCollection linkItemCollection, bool targetExternalLinksToNewWindow) { var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>(); if (linkItemCollection != null) { foreach (var linkItem in linkItemCollection) { var url = new UrlBuilder(linkItem.Href); if (PermanentLinkMapStore.ToMapped(url)) { var pr = PermanentLinkUtility.GetContentReference(url); if (!PageReference.IsNullOrEmpty(pr)) { // page var page = contentLoader.Get <PageData>(pr); if (IsPageAccessible(page)) { linkItem.Href = page.LinkURL; yield return(linkItem); } } else { // document if (IsFileAccessible(linkItem.Href)) { Global.UrlRewriteProvider.ConvertToExternal(url, null, System.Text.Encoding.UTF8); linkItem.Href = url.Path; yield return(linkItem); } } } else if (!linkItem.Href.StartsWith("~")) { // external if (targetExternalLinksToNewWindow && string.IsNullOrEmpty(linkItem.Target)) { linkItem.Target = "_blank"; } if (linkItem.Href.StartsWith("mailto:") || linkItem.Target == "null") { linkItem.Target = string.Empty; } yield return(linkItem); } } } }
public void LinkItemCollectionToStringTest() { var linkItem = new LinkItem("/orders"); linkItem.Name = "ea"; linkItem.Templated = true; linkItem.AddProperty("age", 10); var collection = new LinkItemCollection() { linkItem }; var json = collection.ToString(); }
//public static ContentReference GetSearchPage(this HtmlHelper helper) => ContentLoader.Value.Get<CmsHomePage>(ContentReference.StartPage).SearchPage; private static void AppendFiles(LinkItemCollection files, StringBuilder outputString, string formatString) { if (files == null || files.Count <= 0) { return; } foreach (var item in files.Where(item => !string.IsNullOrEmpty(item.Href))) { var map = _permanentLinkMapper.Value.Find(new UrlBuilder(item.Href)); outputString.AppendLine(map == null ? string.Format(formatString, item.GetMappedHref()) : string.Format(formatString, _urlResolver.Value.GetUrl(map.ContentReference))); } }
public void AddMyAccountMenu(HomePage homePage, HeaderViewModel viewModel) { if (_httpContextAccessor.HttpContext != null && !_httpContextAccessor.HttpContext.User.Identity.IsAuthenticated) { viewModel.UserLinks = new LinkItemCollection(); return; } var menuItems = new LinkItemCollection(); var filter = new FilterContentForVisitor(); var layoutSettings = _settingsService.GetSiteSettings <LayoutSettings>(); foreach (var linkItem in layoutSettings.MyAccountCmsMenu ?? new LinkItemCollection()) { if (!UrlResolver.Current.TryToPermanent(linkItem.Href, out var linkUrl)) { continue; } if (linkUrl.IsNullOrEmpty()) { continue; } var urlBuilder = new UrlBuilder(linkUrl); var content = _urlResolver.Route(urlBuilder); if (content == null || filter.ShouldFilter(content)) { continue; } linkItem.Title = linkItem.Text; menuItems.Add(linkItem); } var signoutText = _localizationService.GetString("/Header/Account/SignOut", "Sign Out"); var link = new LinkItem { Href = "/publicapi/signout", Text = signoutText, Title = signoutText }; link.Attributes.Add("css", "fa-sign-out"); menuItems.Add(link); viewModel.UserLinks.AddRange(menuItems); }
public string Rebase(string value, string fromAppPath, string toAppPath) { //The value being passed in is the raw JSON value stored for the property //We need to identify all links that need to be rebased LinkItemCollection coll = LinkItemCollection.Empty; if (LinkItemCollection.TryParse(value, out coll)) { foreach (LinkItemBase item in coll) { item.RebaseLinkItem(fromAppPath, toAppPath); } } return(coll.ToJSONString()); }
private static void AppendFiles(LinkItemCollection files, StringBuilder outputString, string formatString) { if (files == null || files.Count <= 0) { return; } foreach (var item in files.Where(item => !string.IsNullOrEmpty(item.Href))) { IPermanentLinkMapper mapper = ServiceLocator.Current.GetInstance <IPermanentLinkMapper>(); var map = mapper.Find(new UrlBuilder(item.Href)) as PermanentLinkMap; outputString.AppendLine(map == null ? string.Format(formatString, item.GetMappedHref()) : string.Format(formatString, UrlResolver.Current.GetUrl(map.ContentReference))); } }
/// <summary> /// Returns a sequence with all the EPiServer pages of given type <typeparamref name="T" /> in a LinkItemCollection /// </summary> /// <param name="linkItemCollection">Source LinkItemCollection to look for EPiServer pages.</param> /// <returns>Sequence of the EPiServer pages of type <typeparamref name="T" /> in a LinkItemCollection</returns> public static IEnumerable <T> ToEnumerable <T>(this LinkItemCollection linkItemCollection) where T : PageData { if (linkItemCollection == null) { return(Enumerable.Empty <T>()); } var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>(); return(linkItemCollection .Select(x => x.ToContentReference()) .Where(x => !x.IsNullOrEmpty()) .Select(contentLoader.Get <IContent>) .SafeOfType <T>()); }
public void LinkItemCollectionWithMultipleItemsToStringTest() { var linkItem1 = new LinkItem("/orders"); linkItem1.Name = "ea"; linkItem1.Templated = true; linkItem1.AddProperty("age", 10); var linkItem2 = new LinkItem("/customers"); var collection = new LinkItemCollection() { linkItem1, linkItem2 }; var json = collection.ToString(); }
/// <summary> /// Converts a LinkItemCollection to typed content. Any non-pages will be filtered out. /// </summary> /// <typeparam name="T">Content Type</typeparam> /// <param name="linkItemCollection">The collection of links to convert</param> /// <returns>An enumerable of typed ContentData</returns> public static IEnumerable <T> ToContent <T>(this LinkItemCollection linkItemCollection) where T : IContentData { var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>(); if (linkItemCollection != null) { foreach (var linkItem in linkItemCollection) { var url = new UrlBuilder(linkItem.Href); var content = UrlResolver.Current.Route(url); if (content is T) { yield return((T)content); } } } }
public bool Init(LinkItemCollection linkCollection) { var pdList = new List <PageData>(); foreach (var pages in linkCollection.ToPages()) { pdList.AddRange(ServiceLocator.Current.GetInstance <IContentRepository>().GetChildren <PageData>(pages.PageLink)); } var enumerable = FilterForVisitor.Filter(pdList); foreach (var child in enumerable) { Items.Add(new PageDataItem((PageData)child)); } return(Items.Count != 0); }
public override IList <ContentDetail> FindLinks(string html) { //Looks like when a page is SAVED, this gets called - database records are deleted to track links //These records are scanned when a page is being deleted to detect conflicts //Obviously a more effecient way of doing things as opposed to scanning the whole site for dependencies at once! List <ContentDetail> links = base.FindLinks(html).ToList(); if (links.Count == 0) { //No links found - might be dealing with a LinkItemCollection in which case we have a JSON string if (LinkItemCollection.TryParse(html, out LinkItemCollection linkCollection)) { links = links.Concat(linkCollection.OfType <LinkItem>().Select(x => ContentDetail.Multi(LinkDetailName, false, 0, null, null, x.Url))).ToList(); } } return(links); }
public void GivenMailToLink_WhenHandle_ThenReturnsCorrectMailToLink() { var value = "mailto:[email protected]"; var linkItemCollection = new LinkItemCollection(); linkItemCollection.Add(new EPiServer.SpecializedProperties.LinkItem { Href = value, Text = "any text", Title = "any title" }); var result = ((IEnumerable <LinkItem>) this._sut.Handle(linkItemCollection, null, null)).ToList(); result.Count.ShouldBe(1); result.ShouldContain(x => x.Href == value); result.ShouldContain(x => x.Text == "any text"); result.ShouldContain(x => x.Title == "any title"); }
/// <summary> /// Gets a collection of links for all children to a given page. /// It returns only visible links, which means: /// - not deleted /// - published /// </summary> /// <param name="pageLink"></param> /// <returns></returns> public static LinkItemCollection GetLinkCollectionChildren(PageReference pageLink) { LinkItemCollection result = null; var children = DataFactory.Instance.GetChildren(pageLink); if (children != null && children.Count > 0) { result = new LinkItemCollection(); foreach (var page in children.Where(x => !x.IsDeleted && x.VisibleInMenu && x.CheckPublishedStatus(PagePublishedStatus.Published)) .OrderByDescending(x => x.StartPublish)) { result.Add( new LinkItem { Href = page.LinkURL, Text = page.PageName, Target = "", Title = page.PageName, }); } } return result; }
public static MvcHtmlString RenderExtendedCSS(this HtmlHelper helper, string inline, LinkItemCollection cssFiles) { StringBuilder outputCSS = new StringBuilder(string.Empty); AppendFiles(cssFiles, outputCSS, CssFormat); if (!string.IsNullOrWhiteSpace(inline)) { outputCSS.AppendLine("<style>"); outputCSS.AppendLine(inline); outputCSS.AppendLine("</style>"); } return new MvcHtmlString(outputCSS.ToString()); }
public static MvcHtmlString RenderExtendedCSS(this HtmlHelper helper, string inline, LinkItemCollection cssFiles) { StringBuilder outputCSS = new StringBuilder(string.Empty); StartPage start = ServiceLocator.Current.GetInstance<IContentLoader>().Get<StartPage>(ContentReference.StartPage); if ((cssFiles == null || cssFiles.Count == 0) && start.CSSFiles != null) { AppendFiles(start.CSSFiles, outputCSS, CssFormat); } AppendFiles(cssFiles, outputCSS, CssFormat); if (!string.IsNullOrWhiteSpace(inline)) { outputCSS.AppendLine("<style>"); outputCSS.AppendLine(inline); outputCSS.AppendLine("</style>"); } else { string startCSS; startCSS = start.CSS; outputCSS.AppendLine("<style>"); outputCSS.AppendLine(startCSS); outputCSS.AppendLine("</style>"); } return new MvcHtmlString(outputCSS.ToString()); }
/// <summary> /// Override which creates and adds the content of the control. /// </summary> /// <param name="e"></param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); var items = new LinkItemCollection(); if (DataSource != null) if (DataSource is LinkItemCollection) items = (LinkItemCollection)DataSource; if (items.Count > 0) { AddHeaderTemplate(); for (int i = 0; i < items.Count; i++) { if (i == 0 && FirstItemTemplate != null) AddItemTemplate(FirstItemTemplate, items[i], i + 1); if (i == 1 && SecondItemTemplate != null) AddItemTemplate(SecondItemTemplate, items[i], i + 1); if (i == 2 && ThirdItemTemplate != null) AddItemTemplate(ThirdItemTemplate, items[i], i + 1); if (i == 3 && FourthItemTemplate != null) AddItemTemplate(FourthItemTemplate, items[i], i + 1); if (!_added && i % 2 == 1 && AlternatingItemTemplate != null) AddItemTemplate(AlternatingItemTemplate, items[i], i + 1); if (!_added && ItemTemplate != null) AddItemTemplate(ItemTemplate, items[i], i + 1); if (_added) { _added = false; _addSeparator = true; } } AddFooterTemplate(); } else { HideOrEmpty(); } }
public static MvcHtmlString RenderExtendedScriptFiles(this HtmlHelper helper, LinkItemCollection scriptFiles) { StringBuilder outputCSS = new StringBuilder(string.Empty); AppendFiles(scriptFiles, outputCSS, ScriptFormat); return new MvcHtmlString(outputCSS.ToString()); }
private static void AppendFiles(LinkItemCollection files, StringBuilder outputString, string formatString) { if (files != null && files.Count > 0) { foreach (var item in files) { if (!string.IsNullOrEmpty(item.Href)) { outputString.AppendLine(string.Format(formatString, item.Href)); } } } }