示例#1
0
        private void InOrder(NodeModel rootNode, NodeModel previousNode)
        {
            if (rootNode == null)
            {
                return;
            }

            if (previousNode != null && rootNode.RightChild != null)
            {
                _infix = _infix + "( ";

                InOrder(rootNode.LeftChild, rootNode);

                if (_operatorService.IsOperator(rootNode.Value) || rootNode.Value.Equals(_operatorService.Not))
                {
                    _infix += _operatorService.ConvertAsciiReprentation(rootNode.Value);
                }
                else
                {
                    _infix += rootNode.Value;
                }
                InOrder(rootNode.RightChild, rootNode);

                _infix = _infix + " )";
            }
            else
            {
                InOrder(rootNode.LeftChild, rootNode);

                if (_operatorService.IsOperator(rootNode.Value) || rootNode.Value.Equals(_operatorService.Not))
                {
                    _infix += _operatorService.ConvertAsciiReprentation(rootNode.Value);
                }
                else
                {
                    _infix += rootNode.Value;
                }

                InOrder(rootNode.RightChild, rootNode);
            }
        }