Beispiel #1
0
 void Init()
 {
     root = new MultiTree();
     root.BuildTree(xmlTool.xmlDoc);
     curNode = root;
     InitCell(root.child);
 }
Beispiel #2
0
 public void AddMultiTreeInFile(MultiTree<StringId> multiTree)
 {
     var lines = _treeConverter.ConvertMultiTreeAsMulti(multiTree);
     lines.Insert(0, Environment.NewLine);
     lines.Add(Environment.NewLine);
     File.AppendAllLines(_pathToFile, lines);
 }
Beispiel #3
0
        public MultiTree <TVal> CreateHiberarchyTree()
        {
            MultiTree <TVal> tree = new MultiTree <TVal>();

            tree.Initialize(this.agileMultiTree.Root);
            return(tree);
        }
Beispiel #4
0
		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();
 }
Beispiel #6
0
 /// <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);
     }
 }
Beispiel #7
0
		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);
		}
Beispiel #8
0
 void CeShiInit()
 {
     xmlTool.setPath = "D:/XMLDestroyer/Assets/StreamingAssets/XMLS/Boxian.xml";
     xmlTool.TryRead();
     root.BuildTree(xmlTool.xmlDoc);
     curNode = root;
     InitCell(root.child);
 }
Beispiel #9
0
 public void BackNode()
 {
     if (curNode.parent != null)
     {
         curNode = curNode.parent;
         InitCell(curNode.child);
     }
 }
Beispiel #10
0
    void NextNode()
    {
        var buttonSelf = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;

        curIndex = Convert.ToInt32(buttonSelf.name);
        curNode  = curNode.child[curIndex];
        InitCell(curNode.child);
    }
Beispiel #11
0
 public static MultiTree GetInstance()
 {
     if (_instance == null)
     {
         _instance = new MultiTree();
     }
     return(_instance);
 }
Beispiel #12
0
        public void ShouldTraverseSimpleTree()
        {
            var tree = new MultiTree <int, string>(1);

            tree.AddChild(2);
            tree.AddChild(3);
            CollectionAssert.AreEquivalent(new [] { 1, 2, 3 }, tree);
        }
Beispiel #13
0
    public int DifficultyMode()
    {
        MultiTree.GetInstance().InitTree(idxPlayer);



        return(0);
    }
Beispiel #14
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);
		}
Beispiel #15
0
        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);
        }
Beispiel #16
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);
        }
Beispiel #17
0
		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);
		}
Beispiel #18
0
        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);
        }
Beispiel #19
0
		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);
		}
Beispiel #20
0
        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);
        }
Beispiel #21
0
        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);
        }
Beispiel #22
0
    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);
            }
        }
    }
Beispiel #23
0
		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);
        }
Beispiel #25
0
        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();
 }
Beispiel #28
0
 /// <summary>
 /// 清除所有状态
 /// </summary>
 public static void CleanAll()
 {
     _tree = new MultiTree();
 }