public static TagInfoBase FromXML(string data)
		{
			try
			{
#if SILVERLIGHT
				System.Xml.Linq.XDocument Doc = System.Xml.Linq.XDocument.Load(GenLib.Text.GetStream(data));
				XPathNavigator navigator = Doc.CreateNavigator();
#else
				XPathDocument Doc = new XPathDocument(new StringReader(data));
				XPathNavigator navigator = Doc.CreateNavigator();
#endif

				XPathNavigator node = navigator.SelectSingleNode("/TagInfoBase");
				string tagName = node.GetAttribute("name", "");
				string tagId = node.GetAttribute("id", "");
				string tagIdStr = node.GetAttribute("idStr", "");
				string parentId = node.GetAttribute("parent", "");
				string tagMeta = node.GetAttribute("tagMeta", "");
				TagInfoBase tagInfo = new TagInfoBase();
				tagInfo.TagName = Text.DecodeXMLString(tagName);
				tagInfo.TagId = int.Parse(tagId);
				tagInfo.TagIdStr = Text.DecodeXMLString(tagIdStr);
				tagInfo.ParentTagId = int.Parse(parentId);
				tagInfo.TagMeta = tagMeta != "" ? tagMeta : null;
				return tagInfo;
			}
			catch (Exception)
			{
				return null;
			}
		}
 private void AddChildren(ProjectSpecificConcepts conceptsForm, TagInfoBase tag, TreeNode node, HashSet<int> selectedTags)
 {
     List<TagInfoBase> childTags = conceptsForm.GetTags(tag.TagId);
     foreach (var childTag in childTags)
     {
         TreeNode childNode = node.Nodes.Add(childTag.TagName);
         childNode.Tag = childTag.TagId;
         childNode.Checked = selectedTags.Contains(childTag.TagId);
         AddChildren(conceptsForm, childTag, childNode, selectedTags);
     }
 }
 public int CreateTag(string tagName, string tagIdStr, int parentTagId, string tagMeta = null)
 {
     int tagId = SQLCreateTag(tagName, tagIdStr, parentTagId, tagMeta);
     TagInfoBase tag = new TagInfoBase(tagName, tagId, tagIdStr, parentTagId, tagMeta);
     _tagIdToTagInfo[tagId] = tag;
     if (!string.IsNullOrEmpty(tag.TagIdStr))
         _tagIdStrToTagInfo[tag.TagIdStr] = tag;
     if (!_tagIdToChildrenInfo.ContainsKey(parentTagId))
         _tagIdToChildrenInfo[parentTagId] = new List<TagInfoBase>();
     _tagIdToChildrenInfo[parentTagId].Add(tag);
     return tagId;
 }
 private void UpdateSuggestionsForTag(TagInfoBase tag, Dictionary<string, List<int>> dict)
 {
     if (tag == null)
         return;
     string label = tag.TagName;
     label = label.ToLower();
     label = Text.ReplaceUnicodeCharsWithAscii(label);
     if (label.Contains('\\'))
             label = label.Substring(label.LastIndexOf('\\')+1);
         if (label.Contains('/'))
             label = label.Substring(label.LastIndexOf('/')+1);
     int tagId = tag.TagId;
     for (int i = 1; i <= _prefixConceptMaxSize; i++)
     {
         // if label is too short then break
         if (label.Length < i) break;
         // normalize prefix
         string labelPrefix = label.Substring(0, i);
         // create the suggestion list if not existing yet
         if (!dict.ContainsKey(labelPrefix))
             dict[labelPrefix] = new List<int>();
         // if we already have max number of suggestions for this prefix then do nothing
         if (dict[labelPrefix].Count > _prefixConceptSuggestionCount)
             continue;
         // add the tagid for the prefix
         dict[labelPrefix].Add(tagId);
     }
 }