public static IEnumerable <HtmlControl> FindAll(this IChildrenCollectionProvider container, Predicate <HtmlObject> matchCriteria) { if (!container.HasChildren) { yield return(null); } var queue = new Queue <IChildrenCollectionProvider>(); queue.Enqueue(container); while (queue.Count > 0) { var item = queue.Dequeue(); var itemControl = item as HtmlControl; if (itemControl != null && matchCriteria.Invoke(itemControl)) { yield return(itemControl); } foreach (var childrenCollection in item.GetChildrenCollections()) { foreach (var child in childrenCollection.OfType <HtmlControl>()) { if (matchCriteria.Invoke(child)) { yield return(child); } if (child is IChildrenCollectionProvider) { queue.Enqueue((IChildrenCollectionProvider)child); } } } } }
public static HtmlObject Find(this IChildrenCollectionProvider container, String id) { if (String.IsNullOrEmpty(id)) { return(null); } return(container.Find((c) => id.Equals(c.Id, StringComparison.OrdinalIgnoreCase))); }
public static HtmlObject Find(this IChildrenCollectionProvider container, Type type, String id) { Assert.NullArgument(type, "type"); if (String.IsNullOrEmpty(id)) { return(null); } return(container.Find((c) => type.IsAssignableFrom(c.GetType()) && id.Equals(c.Id, StringComparison.OrdinalIgnoreCase))); }
public static HtmlObject Find(this IChildrenCollectionProvider container, Type type) { Assert.NullArgument(type, "type"); return(container.Find((c) => type.IsAssignableFrom(c.GetType()))); }
public static TControl Find <TControl>(this IChildrenCollectionProvider container) where TControl : HtmlObject { return((TControl)container.Find(typeof(TControl))); }
public static IEnumerable <TControl> FindAll <TControl>(this IChildrenCollectionProvider container) where TControl : HtmlObject { return(container.FindAll((control) => control is TControl).Cast <TControl>()); }
public static HtmlControl Find(this IChildrenCollectionProvider container, Predicate <HtmlObject> matchCriteria) { return(container.FindAll(matchCriteria).FirstOrDefault()); }