/// <summary> /// Get object that matches input tag or ... /// </summary> /// <param name="tag"></param> /// <returns></returns> public TagsStorage GetTagsStorage(Tag2 tag) { TagsStorage result = null; foreach (TagsStorage tagsStorage in this) { if (tagsStorage.name == tag.Name || (tagsStorage.tagType != TagsStorageType.Object)) { if (tag.Child == null) { result = tagsStorage.parent; break; } else { result = tagsStorage.GetTagsStorage(tag.Child); break; } } } if (result == null) { //if (tag.Tags != null) //{ result = this; //} } return(result); }
private void TagStorageToList(ArrayList list, TagsStorage tagsStorage, string separator) { ArrayList parantList = new ArrayList(); string parentString = ""; foreach (TagsStorage tags in tagsStorage) { // if showOnlyTagsOfObjectType is true and type is object then skip this tagsStorage if (this.showOnlyTagsOfObjectType == false || (tags.Type == TagsStorage.TagsStorageType.Object && this.showOnlyTagsOfObjectType == true)) { parentString = ""; parantList.Clear(); GetParentPath(parantList, tags.Parent, false); for (int i = parantList.Count - 1; i >= 0; i--) { parentString = i == parantList.Count - 1 ? string.Concat(parentString, parantList[i].ToString()) : string.Concat(parentString, separator, parantList[i].ToString()); } list.Add(parentString.Equals("") ? tags.Value : string.Concat(parentString, separator, tags.Value)); if (tags.HasChilds) { //parentString = parentString.Equals("") ? tags.Value : string.Concat(parentString, separator, tags.Value); TagStorageToList(list, tags, separator); } } } }
//public TagsLoader() //{ // this.path = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder) + GenericTemplate.constTagsXMLFileName; //} public TagsStorage LoadTags() { TagsStorage rootNode = null; XmlDocument xmlDoc; if (File.Exists(this.path)) { xmlDoc = new XmlDocument(); try { rootNode = new TagsStorage("{=", TagsStorage.TagsStorageType.Object); xmlDoc.Load(path); LoadXMLChild(rootNode, xmlDoc.SelectSingleNode("tags")); } catch (XmlException ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } catch (Exception ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } } return(rootNode); }
/// <summary> /// Add new object /// </summary> /// <param name="tagsStorage"></param> public void Add(TagsStorage tagsStorage) { tagsStorage.parent = this; if (tagsList == null) { tagsList = new ArrayList(); } tagsList.Add(tagsStorage); }
// string.substring private void GetParentPath(ArrayList list, TagsStorage tagsStorage, bool includeRoot) { if (tagsStorage.Parent != null) { list.Add(tagsStorage.Value); GetParentPath(list, tagsStorage.Parent, includeRoot); } else { if (includeRoot == true) { list.Add(tagsStorage.Value); } } }
private void ShowTreeView(TreeNode treeNode, TagsStorage tagsStorage) { TreeNode newTreeNode; foreach (TagsStorage tags in tagsStorage) { // if showOnlyTagsOfObjectType is true and type is object then skip this tagsStorage if (this.showOnlyTagsOfObjectType == false || (tags.Type == TagsStorage.TagsStorageType.Object && this.showOnlyTagsOfObjectType == true)) { newTreeNode = new TreeNode(tags.Value); // tag object hold referenc to tags storage object newTreeNode.Tag = tags; newTreeNode.ToolTipText = tags.Desctiption; treeNode.Nodes.Add(newTreeNode); ShowTreeView(newTreeNode, tags); } } }
private void ShowTreeView(TreeNode treeNode, TagsStorage tagsStorage) { TreeNode newTreeNode; foreach (TagsStorage tags in tagsStorage) { // if showOnlyTagsOfObjectType is true and type is object then skip this tagsStorage if ( this.showOnlyTagsOfObjectType == false || (tags.Type == TagsStorage.TagsStorageType.Object && this.showOnlyTagsOfObjectType == true)) { newTreeNode = new TreeNode(tags.Value); // tag object hold referenc to tags storage object newTreeNode.Tag = tags; newTreeNode.ToolTipText = tags.Desctiption; treeNode.Nodes.Add(newTreeNode); ShowTreeView(newTreeNode, tags); } } }
//public TagsLoader() //{ // this.path = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder) + GenericTemplate.constTagsXMLFileName; //} public TagsStorage LoadTags() { TagsStorage rootNode = null; XmlDocument xmlDoc; if (File.Exists(this.path)) { xmlDoc = new XmlDocument(); try { rootNode = new TagsStorage("{=", TagsStorage.TagsStorageType.Object); xmlDoc.Load(path); LoadXMLChild(rootNode, xmlDoc.SelectSingleNode("tags")); } catch (XmlException ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } catch (Exception ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } } return rootNode; }
public TagsShow(TagsStorage tagsStorage) { this.tagsStorage = tagsStorage; }
private void LoadXMLChild(TagsStorage tagsStorage, XmlNode xmlNode) { TagsStorage newTagsStorage; TagsStorage.TagsStorageType tagsStorageType; foreach (XmlNode node in xmlNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { if (node.Name == "tag") { tagsStorageType = TagsStorage.GetTypeFromString(node.Attributes["type"].Value); if (node.Attributes["type"] != null) { // check if node is type of object // ovo staviti pod isti i, jer je isto code if (node.Attributes["type"].Value == "object") { if (tagsStorage != null) { // if TagsStorage is not null then build nodes newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagsStorageType); tagsStorage.Add(newTagsStorage); if (node.HasChildNodes) { LoadXMLChild(newTagsStorage, node); } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } else { if (tagsStorage != null) { // if TagsStorage is not null then build nodes newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagsStorageType); tagsStorage.Add(newTagsStorage); if (node.HasChildNodes) { LoadXMLChild(newTagsStorage, node); } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } else if (node.Name == "syntax") { tagsStorage.Syntax = node.InnerText; } else if (node.Name == "result") { //lblResult.Text = "Result: " + node.InnerText; } else if (node.Name == "example") { //lblExample.Text = "Example: " + node.InnerText; } else if (node.Name == "desctiption") { tagsStorage.Desctiption = node.InnerText; } else { if (node.HasChildNodes) { LoadXMLChild(tagsStorage, node); } } } } }