void Init() { root = new MultiTree(); root.BuildTree(xmlTool.xmlDoc); curNode = root; InitCell(root.child); }
public void AddMultiTreeInFile(MultiTree<StringId> multiTree) { var lines = _treeConverter.ConvertMultiTreeAsMulti(multiTree); lines.Insert(0, Environment.NewLine); lines.Add(Environment.NewLine); File.AppendAllLines(_pathToFile, lines); }
public MultiTree <TVal> CreateHiberarchyTree() { MultiTree <TVal> tree = new MultiTree <TVal>(); tree.Initialize(this.agileMultiTree.Root); return(tree); }
public void ShouldTraverseSimpleTree() { var tree = new MultiTree<int, string>(1); tree.AddChild(2); tree.AddChild(3); CollectionAssert.AreEquivalent(new [] { 1, 2, 3 }, tree); }
public string ConvertToString(MultiTree<StringId> mainTree, SingleTree<StringId> minorTree) { var lines = _singleTreeConverter.ConvertAsSingleTrees(mainTree, minorTree); var stringBuilder = new StringBuilder(); lines.ForEach(line => stringBuilder.AppendLine(line)); return stringBuilder.ToString(); }
/// <summary> /// 还原状态信息 /// </summary> public static void Restore() { string bakupFile = new IniHelper().ReadValue("StateCenter", "State.Serialize.File.Name", "Iveely.State.Center.ser"); if (File.Exists(bakupFile)) { _tree = Serializer.DeserializeFromFile<MultiTree>(bakupFile); } }
public void ShouldCreateOneNodeForTheSameValue() { var tree = new MultiTree<int, string>(1); var twoNode = tree.AddChild(2); var threeNode = twoNode.AddChild(3); var anotherTreeNode = tree.AddChild(3); Assert.AreSame(threeNode, anotherTreeNode); }
void CeShiInit() { xmlTool.setPath = "D:/XMLDestroyer/Assets/StreamingAssets/XMLS/Boxian.xml"; xmlTool.TryRead(); root.BuildTree(xmlTool.xmlDoc); curNode = root; InitCell(root.child); }
public void BackNode() { if (curNode.parent != null) { curNode = curNode.parent; InitCell(curNode.child); } }
void NextNode() { var buttonSelf = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject; curIndex = Convert.ToInt32(buttonSelf.name); curNode = curNode.child[curIndex]; InitCell(curNode.child); }
public static MultiTree GetInstance() { if (_instance == null) { _instance = new MultiTree(); } return(_instance); }
public void ShouldTraverseSimpleTree() { var tree = new MultiTree <int, string>(1); tree.AddChild(2); tree.AddChild(3); CollectionAssert.AreEquivalent(new [] { 1, 2, 3 }, tree); }
public int DifficultyMode() { MultiTree.GetInstance().InitTree(idxPlayer); return(0); }
public void ShouldTraverseAnotherSimpleTree() { var tree = new MultiTree<int, string>(1); var twoNode = tree.AddChild(2); twoNode.AddChild(3); twoNode.AddChild(4); tree.AddChild(5); CollectionAssert.AreEquivalent(new [] { 1, 2, 3, 4, 5 }, tree); }
public void ShouldCreateOneNodeForTheSameValue() { var tree = new MultiTree <int, string>(1); var twoNode = tree.AddChild(2); var threeNode = twoNode.AddChild(3); var anotherTreeNode = tree.AddChild(3); Assert.AreSame(threeNode, anotherTreeNode); }
public void ShouldTraverseAnotherSimpleTree() { var tree = new MultiTree <int, string>(1); var twoNode = tree.AddChild(2); twoNode.AddChild(3); twoNode.AddChild(4); tree.AddChild(5); CollectionAssert.AreEquivalent(new [] { 1, 2, 3, 4, 5 }, tree); }
public void ShouldRemoveSubtree() { var tree = new MultiTree<int, string>(1); var twoNode = tree.AddChild(2); twoNode.AddChild(3); twoNode.AddChild(4); tree.AddChild(5); tree.RemoveChild(2); CollectionAssert.AreEquivalent(new [] { 1, 5 }, tree); }
public void ShouldRemoveSubtree() { var tree = new MultiTree <int, string>(1); var twoNode = tree.AddChild(2); twoNode.AddChild(3); twoNode.AddChild(4); tree.AddChild(5); tree.RemoveChild(2); CollectionAssert.AreEquivalent(new [] { 1, 5 }, tree); }
public void ShouldRemoveSubtreeFromDictionary() { var tree = new MultiTree<int, string>(1); var twoNode = tree.AddChild(2); twoNode.AddChild(3); twoNode.AddChild(4); tree.AddChild(5); tree.RemoveChild(2); Assert.Throws(typeof(KeyNotFoundException), () => tree.GetNode(2)); Assert.Throws(typeof(KeyNotFoundException), () => tree.GetNode(3)); Assert.Throws(typeof(KeyNotFoundException), () => tree.GetNode(4)); tree.GetNode(5); }
public void ShouldRemoveSubtreeFromDictionary() { var tree = new MultiTree <int, string>(1); var twoNode = tree.AddChild(2); twoNode.AddChild(3); twoNode.AddChild(4); tree.AddChild(5); tree.RemoveChild(2); Assert.Throws(typeof(KeyNotFoundException), () => tree.GetNode(2)); Assert.Throws(typeof(KeyNotFoundException), () => tree.GetNode(3)); Assert.Throws(typeof(KeyNotFoundException), () => tree.GetNode(4)); tree.GetNode(5); }
public Machine() { LocalTimeSource = new SlaveTimeSource(this); LocalTimeSource.TimePassed += HandleTimeProgress; collectionSync = new object(); pausingSync = new object(); disposedSync = new object(); clockSource = new BaseClockSource(); localNames = new Dictionary <IPeripheral, string>(); PeripheralsGroups = new PeripheralsGroupsManager(this); ownLifes = new HashSet <IHasOwnLife>(); pausedState = new PausedState(this); SystemBus = new SystemBus(this); registeredPeripherals = new MultiTree <IPeripheral, IRegistrationPoint>(SystemBus); userStateHook = delegate { }; userState = string.Empty; SetLocalName(SystemBus, SystemBusName); }
void BuildTree(XmlNodeList xmlRoot, MultiTree treeRoot) { for (int i = 0; i < xmlRoot.Count; i++) { XmlNode xmlNode = xmlRoot[i]; MultiTree treeNode = new MultiTree(); treeNode.parent = treeRoot; if (xmlNode.NodeType == XmlNodeType.Element) { treeNode.name = xmlNode.Name; treeRoot.child.Add(treeNode); } else if (xmlNode.NodeType == XmlNodeType.Text) { treeNode.text = xmlNode.InnerText; treeRoot.child.Add(treeNode); } if (xmlNode.HasChildNodes) { BuildTree(xmlNode.ChildNodes, treeNode); } } }
public void ShouldFindRoot() { var tree = new MultiTree<int, string>(1); Assert.AreEqual(1, tree.GetNode(1).Value); }
private Cortege<MultiTree<StringId>, LogHistory> GetMultiTree(List<List<string>> blocks) { Contract.Requires(blocks != null); Contract.Requires(blocks.Any()); Contract.Requires(blocks.Count % 2 == 1); var logHistory = new LogHistory(); var singleTree = _singleTreeParser.GetSingleTree(blocks[0]); logHistory.Add(new SingleTreeResult(singleTree)); var mainTree = new MultiTree<StringId>(singleTree); for (int i = 1; i < blocks.Count; i += 2) { var minorTree = _singleTreeParser.GetSingleTree(blocks[i]); var connectionBlock = blocks[i + 1]; logHistory.Add(new SingleTreeResult(minorTree)); logHistory.Add(new CommandsResult(connectionBlock)); var bindController = new BindContoller<StringId>(mainTree, minorTree); AddConnections(bindController, connectionBlock); var idGenerator = new IdGenerator(mainTree.ToList()); var multiNode = _treeConstructor.GetFilledTree(bindController, idGenerator).ToMultiNode(); mainTree = new MultiTree<StringId>(multiNode); } return new Cortege<MultiTree<StringId>, LogHistory>(mainTree, logHistory); }
public void ShouldFindRoot() { var tree = new MultiTree <int, string>(1); Assert.AreEqual(1, tree.GetNode(1).Value); }
private void ProcessBuildingTreeFromConsole(BindContoller<StringId> bindController = null) { BindContoller<StringId> newBindController = bindController; do { if (newBindController == null) { ProcessBuildingMinorTree(); _consoleConnectionController.Start(new BindContoller<StringId>(_mainMultiTree, _minorSingleTree)); } else { _consoleConnectionController.Start(newBindController); } _mainMultiTree = _consoleConnectionController.GetConnectedMultiTree(); Console.Clear(); Console.WriteLine("Do you want to type another tree?"); Console.WriteLine("type 'yes' to add tree or something else to finish with building trees"); if (Console.ReadLine() != "yes") { break; } newBindController = null; } while (true); _treeLogger.AddMultiTreeInFile(_mainMultiTree); }
private void ProcessBuildingMainTree() { _mainSingleTree = new SingleTree<StringId>(_factory.GetNode("Root", new Root())); ProcessBuildingTree(_mainSingleTree); _treeLogger.AddSinlgeTreeInFile(_mainSingleTree); _mainMultiTree = new MultiTree<StringId>(_mainSingleTree); ProcessBuildingTreeFromConsole(); }
/// <summary> /// 清除所有状态 /// </summary> public static void CleanAll() { _tree = new MultiTree(); }