/// <param name="name">Element name.</param> /// <param name="ident">Identificator of node.</param> /// <param name="strict"></param> /// <returns>null value if not found</returns> protected INodeInfo InfoBy(string name, NodeIdent ident, bool strict) { foreach (INodeInfo info in Inspector.GetBy(ident)) { if (string.IsNullOrEmpty(info.Name)) // hidden property { return(InfoBy(name, info.Link, strict)); } string elem = new StringHandler().ProtectMixedQuotes(info.Name); elem = Regex.Replace(elem, SobaScript.Pattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace); if ((strict && elem == name) || (!strict && elem.Contains(name))) { return(info); } } return(null); }
/// <param name="cmd"></param> /// <param name="component">INodeInfo component for searching.</param> /// <param name="raw">Full raw string to search.</param> /// <returns></returns> protected IEnumerable <INodeInfo> Find(KDataCommand cmd, INodeInfo component, string raw) { if (raw == null) { if (cmd == KDataCommand.CtrlSpace || cmd == KDataCommand.Space) { return(ListInfo(new NodeIdent(component.Name, null))); } return(ListNull); } if (cmd == KDataCommand.Space) { return(ListNull); } string ident = new StringHandler().ProtectMixedQuotes(raw.Trim()); if (IsLatest('.', ident)) { ident = ident.Substring(0, ident.Length - 1); if (cmd == KDataCommand.CtrlSpace) { cmd = KDataCommand.LevelByDot; } } if (cmd == KDataCommand.CtrlSpace) { if (Regex.IsMatch(raw, Pattern.Finalization, RegexOptions.IgnorePatternWhitespace)) { return(ListNull); } } string[] parts = Regex.Replace ( ident, SobaScript.Pattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace ) .Split('.'); NodeIdent id = new NodeIdent(component.Name, null); for (int i = 0; i < parts.Length; ++i) { parts[i] = parts[i].Trim(); if (cmd == KDataCommand.CtrlSpace && i == parts.Length - 1) { return(ListInfo(id, parts[i])); } INodeInfo info = InfoBy(parts[i], id, (cmd == KDataCommand.LevelByDot)); if (info == null) { return(ListEmpty); } id = info.Link; } if (cmd == KDataCommand.LevelByDot) { return(ListInfo(id)); } return(ListEmpty); }