/// <param name="type">Type of element.</param> /// <param name="attr">Found attribute.</param> /// <param name="data"></param> protected void InspectLevelA(Type type, Attribute attr, LInfo data) { if (!IsComponent(type) || (attr.GetType() != typeof(DefinitionAttribute) && attr.GetType() != typeof(ComponentAttribute))) { return; } IAttrDomLevelA levA = (IAttrDomLevelA)attr; NodeIdent ident = new NodeIdent(levA.Parent, null); if (!data.ContainsKey(ident)) { data[ident] = new List <INodeInfo>(); } if (attr.GetType() == typeof(DefinitionAttribute)) { data[ident].Add(new NodeInfo((DefinitionAttribute)attr)); return; } if (attr.GetType() == typeof(ComponentAttribute)) { INodeInfo node = new NodeInfo((ComponentAttribute)attr); data[ident].Add(node); AliasesToNodeLevelA(node, data[ident]); return; } }
/// <param name="type">Type of element.</param> /// <param name="attr">Found attribute.</param> /// <param name="method">Found method.</param> /// <param name="data"></param> protected void InspectLevelB(Type type, Attribute attr, MethodInfo method, LInfo data) { if (!IsComponent(type) || (attr.GetType() != typeof(MethodAttribute) && attr.GetType() != typeof(PropertyAttribute))) { return; } IAttrDomLevelB levB = (IAttrDomLevelB)attr; string className = method.DeclaringType.FullName; NodeIdent ident = new NodeIdent(levB.Parent ?? GetComponentName(type), levB.Method, (levB.Method == null)? null : className); if (!data.ContainsKey(ident)) { data[ident] = new List <INodeInfo>(); } className = (method.Name == null)? null : className; if (attr.GetType() == typeof(PropertyAttribute)) { data[ident].Add(new NodeInfo((PropertyAttribute)attr, method.Name, className)); return; } if (attr.GetType() == typeof(MethodAttribute)) { data[ident].Add(new NodeInfo((MethodAttribute)attr, method.Name, className)); return; } }
/// <summary> /// List of constructed data by identification of node. /// </summary> /// <param name="ident">Identifier of node.</param> /// <returns></returns> public IEnumerable <INodeInfo> GetBy(NodeIdent ident = new NodeIdent()) { if (data.ContainsKey(ident)) { foreach (INodeInfo elem in data[ident].OrderBy(p => p.Name)) { if (IsEnabled(elem.Name)) { yield return(elem); } } } }
/// <param name="ident"></param> /// <returns>node of the hidden level or null value if level is not hidden</returns> protected INodeInfo IsHiddenLevel(NodeIdent ident) { INodeInfo ret = null; foreach (INodeInfo info in Inspector.GetBy(ident)) { if (!string.IsNullOrEmpty(info.Name)) { return(null); } ret = info; } return(ret); }
internal NodeInfo(INodeInfo info, string description = null) { if (info != null) { Name = info.Name; Description = info.Description; Signature = info.Signature; _overname = info.Overname; Aliases = info.Aliases; Type = info.Type; Link = info.Link; } if (description != null) { Description = description; } }
/// <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); }
protected IEnumerable <INodeInfo> ListInfo(NodeIdent ident, string name = null) { INodeInfo hidden = IsHiddenLevel(ident); if (hidden != null) { foreach (INodeInfo inf in ListInfo(hidden.Link, name)) { yield return(inf); } } else { foreach (INodeInfo inf in Inspector.GetBy(ident)) { if (!string.IsNullOrEmpty(name) && !inf.Name.Contains(name)) { continue; } yield return(new NodeInfo(inf, $"{inf.Description}\n{new string('_', 20)}\n{inf.Signature}")); } } }
/// <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); }
/// <param name="name">Element name.</param> /// <param name="description">Description for current element.</param> /// <param name="ident">Binding with other node.</param> /// <param name="type">Element type.</param> /// <param name="overname">Displays element over the 'Name' property.</param> public NodeInfo(string name, string description, NodeIdent ident, NodeType type = NodeType.Unspecified, string overname = null) : this(name, description, type, overname) { Link = ident; }