private bool ShouldFilterNode(CLVBaseNode node, string filter) { bool shouldFilter = false; CLVTagNode tagNode = node as CLVTagNode; CLVComponentNode componentNode = node as CLVComponentNode; if (tagNode != null) { if (FilterBy == FilterType.Component) { tagNode.Children.Filter = ApplyFilter; if (tagNode.Children.IsEmpty) { shouldFilter = true; } } else { shouldFilter = !MatchLabel(tagNode, filter); } } else if (componentNode != null) { if (FilterBy == FilterType.Component) { shouldFilter = !MatchLabel(componentNode, filter); } } return(shouldFilter); }
public CLVBaseNode GetNode(string path) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentException("Node path cannot be empty.", "path"); } CLVBaseNode foundNode = null; string[] splitPath = path.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); // Get the starting parent: if (splitPath.Length > 0) { foundNode = FindTopLevelTag(splitPath[0]); if (foundNode == null) { foundNode = new CLVTagNode(splitPath[0]); m_tagNodeCollection.Add(foundNode); QueueRefilter(); } foundNode = GetChildNode(splitPath, foundNode); } return(foundNode); }
/// <summary> /// The method checks if node should be filtered based on io spec filter. It is used in ApplyFilter. /// If node does not have matching input/outputs it should be filtered out. /// </summary> /// <param name="node">The node.</param> /// <returns>true, if node should be filtered out, false, otherwise</returns> private bool ShouldFilterNodeBasedOnIoSpecFilter(CLVBaseNode node) { bool shouldFilter = false; //apply only to component nodes (not tag nodes) CLVComponentNode componentNode = node as CLVComponentNode; if (componentNode != null) { //if there are any io spec filters if (IoSpecFilters.Count > 0) { //get component or composite component definition IMetadataWithIOSpecDefinition compDef = componentNode.Component as IMetadataWithIOSpecDefinition; // check each io spec filter foreach (IOSpecFilter filter in IoSpecFilters) { //that is not empty if (filter.IsEmpty == false) { if (compDef != null) { //proceed with filtering if (filter.RequiresInput) { //compare the full type (not friendly name) bool match = compDef.IOSpecDefinition.Input.Any(item => item.Value.Type.Equals(filter.FilterByDataType.Value)); if (match == false) { shouldFilter = true; break; } } if (filter.RequiresOutput) { //compare the full type (not friendly name) bool match = compDef.IOSpecDefinition.Output.Any(item => item.Value.Type.Equals(filter.FilterByDataType.Value)); if (match == false) { shouldFilter = true; break; } } } else { //if it was not component metadefinition automatically filter it out (since it has not any input, output) //we check it at this stage, to not exclude it, when the filters are empty shouldFilter = true; break; //just return } } //filter.IsEmpty } // foreach loop } // count > 0 } // component != null return(shouldFilter); }
public override void RemoveChild(CLVBaseNode child) { CLVReferenceNode reference = child as CLVReferenceNode; if (reference != null) { base.RemoveChild(child); } }
private bool MatchLabel(CLVBaseNode node, string filter) { if (node == null) { throw new ArgumentNullException("node"); } string label = node.Label.ToLower(); return(label.Contains(filter)); }
internal bool ApplyFilter(object item) { CLVBaseNode metadataDefinition = item as CLVBaseNode; if (metadataDefinition == null) { return(false); } return(!ShouldFilterNode(metadataDefinition, m_lowercaseFilter) && !ShouldFilterNodeBasedOnIoSpecFilter(metadataDefinition)); }
public void AddTag(string tag) { CLVBaseNode parent = m_componentsLibrary.GetNode(tag); if (parent == null) { throw new InvalidOperationException(); } parent.AddChild(this); m_parents.Add(parent); }
public override void AddChild(CLVBaseNode child) { CLVReferenceNode reference = child as CLVReferenceNode; if (reference == null) { throw new ArgumentException("Child must be of type CLVReferenceNode", "child"); } HasError |= !reference.Exists; base.AddChild(child); }
private void RemoveTag(string tag) { CLVBaseNode parent = m_componentsLibrary.GetNode(tag); if (parent == null) { throw new InvalidOperationException(); } parent.RemoveChild(this); m_parents.Remove(parent); }
/// <summary> /// Removes the child node from this instance. /// </summary> /// <param name="child">The child.</param> public virtual void RemoveChild(CLVBaseNode child) { if (child == null) { throw new ArgumentNullException(); } if (m_children == null) { throw new InvalidOperationException(); } m_children.Remove(child); }
private CLVBaseNode FindTopLevelTag(string tag) { CLVBaseNode found = null; foreach (CLVBaseNode node in m_tagNodeCollection) { if (node.Label == tag) { found = node; break; } } return(found); }
private void RemoveEmptySubTag(string[] tags, int index, CLVBaseNode parent) { if (index < tags.Length) { var found = parent.AllChildren.FirstOrDefault(o => { return(o.Label.Equals(tags[index], StringComparison.CurrentCultureIgnoreCase)); }); if (found != null) { RemoveEmptySubTag(tags, index++, found); if (found.AllChildren.Count == 0) { parent.RemoveChild(found); } } } }
private CLVBaseNode GetChildNode(string[] splitPath, CLVBaseNode parent) { for (int i = 1; i < splitPath.Length; ++i) { var found = parent.AllChildren.FirstOrDefault(o => { return(o.Label.Equals(splitPath[i], StringComparison.CurrentCultureIgnoreCase)); }); if (found == null) { found = new CLVTagNode(splitPath[i]); parent.AddChild(found); } parent = found; } return(parent); }
/// <summary> /// Adds the child node to this instance. /// </summary> /// <param name="child">The child.</param> public virtual void AddChild(CLVBaseNode child) { if (child == null) { throw new ArgumentNullException(); } if (m_children == null) { throw new InvalidOperationException(); } if (!m_children.Contains(child)) { m_children.Add(child); } }
public override void RemoveChild(CLVBaseNode child) { throw new InvalidOperationException(); }
/// <summary> /// Adds the child node to this instance. /// </summary> /// <param name="child">The child.</param> public virtual void AddChild(CLVBaseNode child) { if (child == null) throw new ArgumentNullException(); if (m_children == null) throw new InvalidOperationException(); if (!m_children.Contains(child)) { m_children.Add(child); } }
/// <summary> /// The method checks if node should be filtered based on io spec filter. It is used in ApplyFilter. /// If node does not have matching input/outputs it should be filtered out. /// </summary> /// <param name="node">The node.</param> /// <returns>true, if node should be filtered out, false, otherwise</returns> private bool ShouldFilterNodeBasedOnIoSpecFilter(CLVBaseNode node) { bool shouldFilter = false; //apply only to component nodes (not tag nodes) CLVComponentNode componentNode = node as CLVComponentNode; if (componentNode != null) { //if there are any io spec filters if (IoSpecFilters.Count > 0) { //get component or composite component definition IMetadataWithIOSpecDefinition compDef = componentNode.Component as IMetadataWithIOSpecDefinition; // check each io spec filter foreach (IOSpecFilter filter in IoSpecFilters) { //that is not empty if (filter.IsEmpty == false) { if (compDef != null) { //proceed with filtering if (filter.RequiresInput) { //compare the full type (not friendly name) bool match = compDef.IOSpecDefinition.Input.Any(item => item.Value.Type.Equals(filter.FilterByDataType.Value)); if (match == false) { shouldFilter = true; break; } } if (filter.RequiresOutput) { //compare the full type (not friendly name) bool match = compDef.IOSpecDefinition.Output.Any(item => item.Value.Type.Equals(filter.FilterByDataType.Value)); if (match == false) { shouldFilter = true; break; } } } else { //if it was not component metadefinition automatically filter it out (since it has not any input, output) //we check it at this stage, to not exclude it, when the filters are empty shouldFilter = true; break; //just return } } //filter.IsEmpty } // foreach loop } // count > 0 } // component != null return shouldFilter; }
private bool ShouldFilterNode(CLVBaseNode node, string filter) { bool shouldFilter = false; CLVTagNode tagNode = node as CLVTagNode; CLVComponentNode componentNode = node as CLVComponentNode; if (tagNode != null) { if (FilterBy == FilterType.Component) { tagNode.Children.Filter = ApplyFilter; if (tagNode.Children.IsEmpty) { shouldFilter = true; } } else { shouldFilter = !MatchLabel(tagNode, filter); } } else if(componentNode != null) { if (FilterBy == FilterType.Component) { shouldFilter = !MatchLabel(componentNode, filter); } } return shouldFilter; }
private bool MatchLabel(CLVBaseNode node, string filter) { if(node == null) throw new ArgumentNullException("node"); string label = node.Label.ToLower(); return label.Contains(filter); }
private CLVBaseNode GetChildNode(string[] splitPath, CLVBaseNode parent) { for (int i = 1; i < splitPath.Length; ++i) { var found = parent.AllChildren.FirstOrDefault(o => { return o.Label.Equals(splitPath[i], StringComparison.CurrentCultureIgnoreCase); }); if (found == null) { found = new CLVTagNode(splitPath[i]); //m_tagNodeCollection.Add(found); parent.AddChild(found); QueueRefilter(); } parent = found; } return parent; }
public override void AddChild(CLVBaseNode child) { CLVReferenceNode reference = child as CLVReferenceNode; if (reference == null) throw new ArgumentException("Child must be of type CLVReferenceNode", "child"); HasError |= !reference.Exists; base.AddChild(child); }
/// <summary> /// Removes the child node from this instance. /// </summary> /// <param name="child">The child.</param> public virtual void RemoveChild(CLVBaseNode child) { if (child == null) throw new ArgumentNullException(); if (m_children == null) throw new InvalidOperationException(); m_children.Remove(child); }
public override void AddChild(CLVBaseNode child) { throw new InvalidOperationException(); }
private void RemoveEmptySubTag(string[] tags, int index, CLVBaseNode parent) { if (index < tags.Length) { var found = parent.AllChildren.FirstOrDefault(o => { return o.Label.Equals(tags[index], StringComparison.CurrentCultureIgnoreCase); }); if (found != null) { RemoveEmptySubTag(tags, index++, found); if (found.AllChildren.Count == 0) { parent.RemoveChild(found); } } } }