/// <summary> /// returns a Node Matching the Key supplied, for either a /// DefaultBrowser, or Gatway/Browser node. /// </summary> /// <param name="Key"></param> /// <returns></returns> private Node GetNode(string Key) { if (Key == null || Key.Length == 0) { return(null); } string filename; //Must find what file node that this key is located in //so we look it up in the string dictionary's if (!BrowserKeys.TryGetValue(Key, out filename) && !DefaultKeys.TryGetValue(Key, out filename)) { return(null); } //fxcop sugguested this was faster then //filename!= string.Empty if (filename != null && filename.Length > 0) { //now that we have a name we look it up in the hasttable containing //the actual node. nBrowser.File b = Browserfiles[filename]; Node n = b.GetNode(Key); return(n); } return(null); }
private void AddBrowserFile(nBrowser.File file) { if (Browserfiles.ContainsKey(file.FileName) == false) { Browserfiles.Add(file.FileName, file); nbrowserfiles.Add(file); string[] keys = file.Keys; for (int i = 0; i <= keys.Length - 1; i++) { if (BrowserKeys.ContainsKey(keys[i]) == false) { BrowserKeys.Add(keys[i], file.FileName); } else { throw new nBrowser.Exception("Duplicate Key \"" + keys[i] + "\" found in " + file.FileName + " and in file " + BrowserKeys[keys[i]]); } } keys = file.DefaultKeys; for (int i = 0; i <= keys.Length - 1; i++) { if (DefaultKeys.ContainsKey(keys[i]) == false) { DefaultKeys.Add(keys[i], file.FileName); } else { throw new nBrowser.Exception("Duplicate Key \"" + keys[i] + "\" found in " + file.FileName + " and in file " + DefaultKeys[keys[i]]); } } } }
/// <summary> /// Reads a browser file and builds the Nodes which that file contains. /// </summary> /// <param name="filename"></param> public void AddBrowserFile(string fileName) { if (Browserfiles.ContainsKey(fileName) == false) { nBrowser.File b = new nBrowser.File(fileName); this.AddBrowserFile(b); } }
public void AddBrowserFile(System.Xml.XmlDocument browser, string fileName) { if (Browserfiles.ContainsKey(fileName) == false) { nBrowser.File file = new nBrowser.File(browser, fileName); this.AddBrowserFile(file); } }
/// <summary> /// Returns an Array of Nodes that have been built. To be used for Design/Editors of Browser /// files. /// </summary> /// <returns></returns> public Node[] Nodes() { Node[] browsers; nBrowser.File[] files = new nBrowser.File[Browserfiles.Count]; Browserfiles.Values.CopyTo(files, 0); int count = 0; for (int i = 0; i <= files.Length - 1; i++) { count += files[i].Nodes.Length; } browsers = new Node[count]; count = 0; for (int i = 0; i <= files.Length - 1; i++) { for (int a = 0; a <= files[i].Nodes.Length - 1; a++) { browsers[count] = files[i].Nodes[a]; count++; } } return(browsers); }
/// <summary> /// Returns an Array of Nodes that have been built. To be used for Design/Editors of Browser /// files. /// </summary> /// <returns></returns> public Node[] Nodes() { Node[] browsers; nBrowser.File[] files = new nBrowser.File[Browserfiles.Count]; Browserfiles.Values.CopyTo(files, 0); int count = 0; for (int i = 0;i <= files.Length - 1;i++) { count += files[i].Nodes.Length; } browsers = new Node[count]; count = 0; for (int i = 0;i <= files.Length - 1;i++) { for (int a = 0;a <= files[i].Nodes.Length - 1;a++) { browsers[count] = files[i].Nodes[a]; count++; } } return browsers; }
private Node InitializeTree() { Node root = new Node(); //Custom Sorted List, to allow where Multple files in Diff directorys might have the same //filename. So still to some degree first come first serve but might be close enough //to how microsoft System to match much more closely. System.Collections.Generic.SortedList<string, System.Collections.Generic.List<nBrowser.File>> list; list = new System.Collections.Generic.SortedList<string, System.Collections.Generic.List<nBrowser.File>>(); for (int i = 0;i <= Browserfiles.Count - 1;i++) { if (list.ContainsKey(nbrowserfiles[i].FileName) == false) { System.Collections.Generic.List<nBrowser.File> l; l = new System.Collections.Generic.List<nBrowser.File>(); list.Add(nbrowserfiles[i].FileName, l); } list[nbrowserfiles[i].FileName].Add(nbrowserfiles[i]); } nBrowser.File[] files = new nBrowser.File[Browserfiles.Count]; int count = 0; for (int i = 0;i <= list.Count - 1;i++) { System.Collections.Generic.List<nBrowser.File> l = list[list.Keys[i]]; for (int b = 0;b <= l.Count - 1;b++) { files[count] = l[b]; count++; } } #region Connect Nodes for (int i = 0;i <= Browserfiles.Count - 1;i++) { for (int a = 0;a <= files[i].Keys.Length - 1;a++) { Node child = files[i].GetNode(files[i].Keys[a]); Node parent = null; if (child.ParentId.Length > 0) { parent = this.GetNode(child.ParentId); if (parent == null) throw new nBrowser.Exception(String.Format("Parent not found with id = {0}", child.ParentId)); } if (parent == null) parent = root; parent.AddChild(child); } } #endregion #region Inject DefaultBrowser Nodes for (int i = 0;i <= Browserfiles.Count - 1;i++) { for (int a = 0;a <= files[i].DefaultKeys.Length - 1;a++) { Node defaultNode = files[i].GetDefaultNode(files[i].DefaultKeys[a]); Node node = this.GetNode(defaultNode.Id); if (node == defaultNode) { // there is no regular node so the defaultNode is already at // the correct spot in the tree. continue; } Node parentNode = this.GetNode(node.ParentId); if (parentNode == null) parentNode = root; // insert the default node between the regular node and it's parent. parentNode.RemoveChild(node); defaultNode.AddChild(node); parentNode.AddChild(defaultNode); } } #endregion #region Merge Ref Nodes for (int i = 0;i <= Browserfiles.Count - 1;i++) { foreach (Node refNode in files[i].RefNodes) { GetNode(refNode.RefId).MergeFrom(refNode); } } #endregion return root; }
private Node InitializeTree() { Node root = new Node(); //Custom Sorted List, to allow where Multple files in Diff directorys might have the same //filename. So still to some degree first come first serve but might be close enough //to how microsoft System to match much more closely. System.Collections.Generic.SortedList <string, System.Collections.Generic.List <nBrowser.File> > list; list = new System.Collections.Generic.SortedList <string, System.Collections.Generic.List <nBrowser.File> >(); for (int i = 0; i <= Browserfiles.Count - 1; i++) { if (list.ContainsKey(nbrowserfiles[i].FileName) == false) { System.Collections.Generic.List <nBrowser.File> l; l = new System.Collections.Generic.List <nBrowser.File>(); list.Add(nbrowserfiles[i].FileName, l); } list[nbrowserfiles[i].FileName].Add(nbrowserfiles[i]); } nBrowser.File[] files = new nBrowser.File[Browserfiles.Count]; int count = 0; for (int i = 0; i <= list.Count - 1; i++) { System.Collections.Generic.List <nBrowser.File> l = list[list.Keys[i]]; for (int b = 0; b <= l.Count - 1; b++) { files[count] = l[b]; count++; } } #region Connect Nodes for (int i = 0; i <= Browserfiles.Count - 1; i++) { for (int a = 0; a <= files[i].Keys.Length - 1; a++) { Node child = files[i].GetNode(files[i].Keys[a]); Node parent = null; if (child.ParentId.Length > 0) { parent = this.GetNode(child.ParentId); if (parent == null) { throw new nBrowser.Exception(String.Format("Parent not found with id = {0}", child.ParentId)); } } if (parent == null) { parent = root; } parent.AddChild(child); } } #endregion #region Inject DefaultBrowser Nodes for (int i = 0; i <= Browserfiles.Count - 1; i++) { for (int a = 0; a <= files[i].DefaultKeys.Length - 1; a++) { Node defaultNode = files[i].GetDefaultNode(files[i].DefaultKeys[a]); Node node = this.GetNode(defaultNode.Id); if (node == defaultNode) { // there is no regular node so the defaultNode is already at // the correct spot in the tree. continue; } Node parentNode = this.GetNode(node.ParentId); if (parentNode == null) { parentNode = root; } // insert the default node between the regular node and it's parent. parentNode.RemoveChild(node); defaultNode.AddChild(node); parentNode.AddChild(defaultNode); } } #endregion #region Merge Ref Nodes for (int i = 0; i <= Browserfiles.Count - 1; i++) { foreach (Node refNode in files[i].RefNodes) { GetNode(refNode.RefId).MergeFrom(refNode); } } #endregion return(root); }