public bool LoadMenuItems(ref string items) { _children = new HtmlElement_menuItemCollection(this.RootPointer, this); if (items.Length > 0) { if (items.StartsWith("[", StringComparison.Ordinal)) { items = items.Substring(1); int pos = items.IndexOf(';'); if (pos > 0) { this.SetId(items.Substring(0, pos)); items = items.Substring(pos + 1); } pos = items.IndexOf(']'); int pos2 = items.IndexOf('['); if (pos2 >= 0 && pos2 < pos) { pos = pos2; } if (pos < 0) { items = string.Empty; return(false); } _text = items.Substring(0, pos); if (items[pos] == ']') { items = items.Substring(pos + 1); items = items.Trim(); return(true); } items = items.Substring(pos); items = items.Trim(); while (items.Length > 0 && !items.StartsWith("]", StringComparison.Ordinal)) { HtmlElement_menuItem mi = new HtmlElement_menuItem(this.RootPointer); if (mi.LoadMenuItems(ref items)) { _children.Add(mi); } else { break; } } if (items.Length > 0 && items.StartsWith("]", StringComparison.Ordinal)) { items = items.Substring(1); items = items.Trim(); return(true); } } } items = string.Empty; return(false); }
public void LoadMenuItems(string items) { _children = new HtmlElement_menuItemCollection(this.RootPointer, this); if (!string.IsNullOrEmpty(items)) { items = items.Trim(); while (items.Length > 0) { HtmlElement_menuItem mi = new HtmlElement_menuItem(this.RootPointer); if (mi.LoadMenuItems(ref items)) { _children.Add(mi); } } } }