public override string getNodeName(IObjectWithPathAndChildSelector source, string defName = "") { string output = defName; if (source is IContentPage) { output = "C"; } else if (source is IContentBlock) { output = "B"; } else if (source is IContentParagraph) { output = "P"; } else if (source is IContentSentence) { output = "S"; } else if (source is IContentToken) { output = "T"; } if (source is IContentElement) { IContentElement source_IContentToken = (IContentElement)source; output = output + source_IContentToken.id; } return(output); }
public override string getNodeDescription(IObjectWithPathAndChildSelector source, string defDescription = "") { string output = defDescription; if (source is IContentPage) { output = output.add("Page", " "); } else if (source is IContentBlock) { output = output.add("Block", " "); // "Block"; } else if (source is IContentParagraph) { output = output.add("Paragraph", " "); } else if (source is IContentSentence) { output = output.add("Sentence", " "); } else if (source is IContentToken) { output = output; //IContentToken source_IContentToken = (IContentToken)source; //String tkn = source_IContentToken.content.TrimToMaxLength(5, "..."); //output = output.add(tkn, " "); } return(output); }
public virtual string getNodeDescription(IObjectWithPathAndChildSelector source, string defDescription = "") { if (source is IObjectWithNameAndDescription) { IObjectWithNameAndDescription child_IObjectWithNameAndDescription = (IObjectWithNameAndDescription)source; return(child_IObjectWithNameAndDescription.description); } return(defDescription); }
//public virtual /// <summary> /// Builds a node. /// </summary> /// <param name="model">The diagram model.</param> /// <param name="source">The source object to build from</param> /// <returns></returns> public override diagramNode buildNode(diagramModel model, IObjectWithPathAndChildSelector source) { string name = getNodeName(source, "NaN"); string description = getNodeDescription(source, name); diagramNode node = model.AddNode(description, diagramNodeShapeEnum.normal, name); node.relatedObject = source; return(node); }
/// <summary> /// Sets target and automatically Update - sets all switches if options used /// </summary> /// <param name="target">The target.</param> /// <param name="setSwitches">if set to <c>true</c> it will set state switches to <c>switchValueToSet</c> value</param> /// <param name="switchValueToSet">Value to set to switches, if <c>setSwitches</c> is <c>true</c></param> public ObjectPathParentAndRootMonitor(IObjectWithPathAndChildSelector target, Boolean setSwitches = false, Boolean switchValueToSet = true) { update(target); if (setSwitches) { state.IsChildrenCountChanged = switchValueToSet; state.IsParentChanged = switchValueToSet; state.IsPathChanged = switchValueToSet; state.IsRootChanged = switchValueToSet; state.IsTargetChanged = switchValueToSet; state.IsChanged = switchValueToSet; } }
/// <summary> /// Discovers relative path to <c>target</c> member of the structure /// </summary> /// <param name="source">The source.</param> /// <param name="target">The target.</param> /// <returns>String that leads to target</returns> public static string getPathTo(this IObjectWithPathAndChildSelector source, IObjectWithPathAndChildSelector target) { String t_path = target.path; String s_path = source.path; String c_path = t_path.getCommonRoot(s_path, false); String c_to_t = imbSciStringExtensions.removeStartsWith(t_path, c_path); IObjectWithPathAndChildSelector root = source.getParentOrRoot() as IObjectWithPathAndChildSelector; IObjectWithPathAndChildSelector common = root.getChildByPath(c_path) as IObjectWithPathAndChildSelector; // root.getChild(c_to_t); String s_to_c = source.getPathToParent(common); String output = s_to_c.add(c_to_t, PATHSPLITER); return(output); }
/// <summary> /// Builds the diagram model from an object with children /// </summary> /// <param name="source">The source.</param> /// <returns></returns> public override diagramModel buildModel(diagramModel output, IObjectWithPathAndChildSelector source) { if (source == null) { throw new ArgumentNullException("can-t build model :: source is null" + "Diagram = source is null"); } if (output == null) { output = new diagramModel("", "", diagramDirectionEnum.LR); if (source is IObjectWithNameAndDescription) { IObjectWithNameAndDescription source_IObjectWithNameAndDescription = (IObjectWithNameAndDescription)source; output.name = source_IObjectWithNameAndDescription.name; output.description = source_IObjectWithNameAndDescription.description; } } diagramNode parent = buildNode(output, source); //parent.relatedObject = source; List <diagramNode> childNodes = new List <diagramNode>(); childNodes = buildChildren(output, parent, source, diagramNodeShapeEnum.normal, diagramLinkTypeEnum.normal, true); int c = 1; while (childNodes.Any()) { c++; if (c > childDepthLimit) { break; } List <diagramNode> newChildNodes = new List <diagramNode>(); foreach (diagramNode childNode in childNodes) { if (childNode.relatedObject is IEnumerable) { newChildNodes.AddRange(buildChildren(output, childNode, childNode.relatedObject as IEnumerable, diagramNodeShapeEnum.normal, diagramLinkTypeEnum.normal, true)); } } childNodes = newChildNodes; } return(output); }
/// <summary> /// Tests <c>test</c> vs <c>currentScope</c> relationship /// </summary> /// <param name="currentScope">The current scope.</param> /// <param name="test">The test.</param> /// <param name="testScope">The test scope.</param> /// <returns></returns> /// <remarks> /// <para>Target enums supported:</para> /// Same element /// <see cref = "metaModelTargetEnum.scope" /> /// <c>test</c> is direct child of <c>currentScope</c> /// <see cref="metaModelTargetEnum.scopeChild"/> /// <c>test</c> is child at any level of <c>currentScope</c> /// <see cref="metaModelTargetEnum.scopeEachChild"/> /// <c>test</c> is parent at any level of <c>currentScope</c> /// <see cref="metaModelTargetEnum.scopeParent"/> /// <c>test</c> is not null /// <see cref="metaModelTargetEnum.scopeRelativePath"/> /// /// For any other <see cref="metaModelTargetEnum"/> value it will return <c>false</c>, except for <see cref="metaModelTargetEnum.none"/> returns <c>true</c> /// </remarks> /// <seealso cref="metaModelTargetEnum.scope"/> /// <seealso cref="metaModelTargetEnum.scopeChild"/> /// <seealso cref="metaModelTargetEnum.scopeEachChild"/> /// <seealso cref="metaModelTargetEnum.scopeParent"/> /// <seealso cref="metaModelTargetEnum.scopeRelativePath"/> public static Boolean testScope(this IObjectWithPathAndChildSelector currentScope, IObjectWithPathAndChildSelector test, metaModelTargetEnum testScope) { if (test == null) { return(false); } switch (testScope) { default: return(false); break; case metaModelTargetEnum.none: return(true); break; case metaModelTargetEnum.scope: return(currentScope == test); break; case metaModelTargetEnum.scopeChild: return(test.parent == currentScope); break; case metaModelTargetEnum.scopeEachChild: return(test.path.StartsWith(currentScope.path)); break; case metaModelTargetEnum.scopeParent: return(currentScope.path.StartsWith(test.path)); break; case metaModelTargetEnum.scopeRelativePath: return(test != null); break; } return(false); }
/// <summary> /// Checks for changes and records it into internal change switches /// </summary> /// <param name="target">Monitored object</param> public void update(IObjectWithPathAndChildSelector target) { if (State == null) { State = new ObjectScopeChangeReport(); } if (lastTarget != target) { State.IsTargetChanged = true; lastTarget = target; } if (target == null) { return; } if (lastPath != target.path) { State.IsPathChanged = true; lastPath = target.path; } if (lastParent != target.parent) { State.IsParentChanged = true; lastParent = target.parent; } if (lastRoot != target.root) { State.IsRootChanged = true; lastRoot = target.root; } if (lastChildrenCount != target.Count()) { State.IsChildrenCountChanged = true; lastChildrenCount = target.Count(); } }
public override diagramNodeShapeEnum getShapeTypeEnum(IObjectWithPathAndChildSelector child, diagramNodeShapeEnum defType = diagramNodeShapeEnum.normal) { if (child is IContentBlock) { return(diagramNodeShapeEnum.circle); } if (child is IContentParagraph) { return(diagramNodeShapeEnum.rhombus); } if (child is IContentSentence) { return(diagramNodeShapeEnum.rounded); } if (child is IContentToken) { return(diagramNodeShapeEnum.normal); } return(defType); }
public abstract diagramNode buildNode(diagramModel model, IObjectWithPathAndChildSelector source);
public abstract diagramModel buildModel(diagramModel output, IObjectWithPathAndChildSelector source);
public virtual diagramNodeShapeEnum getShapeTypeEnum(IObjectWithPathAndChildSelector child, diagramNodeShapeEnum defType = diagramNodeShapeEnum.normal) { return(defType); }