public override string GetHTML(int deep = 0) { /// <summary> /// Вложеные элементы могут быть только source /// </summary> Childs = Childs.Where(x => x is source).ToList(); if (Childs.Count == 0) { SetAttribute("src", src); } if (autoplay) { SetAttribute("autoplay", "autoplay"); } else { SetAttribute("preload", preload.ToString("g")); } if (controls) { SetAttribute("controls", "controls"); } if (loop) { SetAttribute("loop", "loop"); } return(base.GetHTML(deep)); }
private IEnumerable <string> GetSubscribersFor(IEnumerable <string> variablePath) { var subscribers = new List <string>(); if (variablePath.Any()) { foreach (var child in Childs.Where(item => item.Key == variablePath.FirstOrDefault())) { subscribers.AddRange(child.Value.GetSubscribersFor(variablePath.Skip(1))); } } else { return(Subscribers.Keys); } return(subscribers); }
public override List <MainListWrapper> GetDirectChildren() { List <MainListWrapper> wrappers = new List <MainListWrapper>(); AnimeGroupVM.SortMethod = AnimeGroupSortMethod.SortName; if (Childs.Count > 0) { wrappers.AddRange(Childs.Where(a => MainListHelperVM.Instance.AllGroupFiltersDictionary.ContainsKey(a)).Select(a => MainListHelperVM.Instance.AllGroupFiltersDictionary[a]).Where(a => !a.IsLocked || (a.IsLocked && a.HasGroupChilds())).OrderBy(a => a.FilterName)); } else { if (Groups.ContainsKey(JMMServerVM.Instance.CurrentUser.JMMUserID.Value)) { foreach ( AnimeGroupVM grp in Groups[JMMServerVM.Instance.CurrentUser.JMMUserID.Value].Select( a => MainListHelperVM.Instance.AllGroupsDictionary[a])) { if (grp.AnimeGroupParentID.HasValue) { continue; } if (grp.AllAnimeSeries.Count == 1) { wrappers.Add(grp.AllAnimeSeries[0]); } else { wrappers.Add(grp); } } } } if (wrappers.Count != GroupsCount) { GroupsCount = wrappers.Count; } return(wrappers); }
public override bool Equals(object obj) { var rVal = obj as Node; if (rVal == null) { return(false); } if (Id != rVal.Id) { return(false); } if (Name != rVal.Name) { return(false); } if (TypeVal != rVal.TypeVal) { return(false); } if (Val != rVal.Val) { return(false); } if (Val != rVal.Val) { return(false); } //if (ParrentId != rVal.ParrentId) // return false; if (Childs.Where((el, i) => rVal.Childs[i].Id != el.Id).Any()) { return(false); } return(true); }
public SherlockNode this[string id] { get { if (Type == NodeType.Leaf) { throw new InvalidOperationException(); } var nodes = Childs.Where(x => x.Name == id); if (nodes.Any()) { return(nodes.Single()); } var retVal = new SherlockNode { Name = id }; Childs.Add(retVal); return(retVal); } set { var v = Childs.Where(x => x.Name == id).FirstOrDefault(); if (v == null) { v = new SherlockNode { Name = id }; Childs.Add(v); } v.Childs.Add(value); } }
public new IEnumerable <VMFile> GetSelectedFiles() { return(Childs.Where(T => T.IsSelected)); }
public override string GetHTML(int deep = 0) { Childs = Childs.Where(x => x is option).ToList(); return(base.GetHTML(deep)); }
/// <summary>按名称查找。实体缓存</summary> /// <param name="name">地区名称</param> /// <param name="withLike">未找到时,是否查找相似的地区。因为地区可能有市、县、区等字样,而查询名称没填</param> /// <param name="deepth">地区路径的最大可能层次。内置地区数据库只有三层</param> /// <returns></returns> public EntityList <TEntity> FindAllByName(String name, Boolean withLike = true, Int32 deepth = 0) { if (String.IsNullOrEmpty(name)) { return(null); } if (deepth <= 0) { if ((this as IEntity).IsNullKey) { deepth = 3; } else if (this.Parent == null || (this.Parent as IEntity).IsNullKey) { deepth = 2; } else { deepth = 1; } } //EntityList<TEntity> list = Meta.Cache.Entities.FindAll(__.Name, name); //EntityList<TEntity> list = Childs.FindAll(__.Name, name); EntityList <TEntity> list = Childs.FindAll(a => CompAreaName(a.Name, name)); if (list != null && list.Count > 0) { return(list); } // 试试下一级 if (deepth >= 2) { // 先用严格查找,再用模糊查找,避免在严格匹配项之前就匹配了模糊项 foreach (var item in Childs) { list = item.FindAllByName(name, false, deepth - 1); if (list != null && list.Count > 0) { return(list); } } if (withLike) { foreach (var item in Childs) { list = item.FindAllByName(name, withLike, deepth - 1); if (list != null && list.Count > 0) { return(list); } } } } if (!withLike) { return(list); } // 未找到,开始模糊查找 //String[] names = Meta.Cache.Entities.Select<TEntity, String>(e => e.Name).ToArray(); String[] names = Childs.Select <TEntity, String>(e => e.Name).ToArray(); String[] rs = StringHelper.LCSSearch(name, names); if (rs != null && rs.Length > 0) { list = new EntityList <TEntity>(Childs.Where <TEntity>(e => rs.Contains(e.Name, StringComparer.OrdinalIgnoreCase))); return(list); } // 如果层次大于1,开始拆分。比如江苏省南京市鼓楼区,第一段至少一个字 if (deepth > 1) { // 应该从右往左,这样子才能做到最大匹配,否则会因为模糊查找而混杂很多其它东西 //for (int i = name.Length - 1; i >= 1; i--) for (int i = 0; i < name.Length; i++) { String first = name.Substring(0, i); String last = name.Substring(i); // 必须找到左边的,否则这个匹配没有意义 //TEntity entity = Meta.Cache.Entities.Find(__.Name, first); // 模糊查询一层 var list2 = FindAllByName(first, true, 1); if (list2 != null && list2.Count > 0) { foreach (var item in list2) { list = item.FindAllByName(last, withLike, deepth - 1); if (list != null && list.Count > 0) { return(list); } } } } } return(list); }