Пример #1
0
        public virtual ISolutionTreeNode FindTreeNode(ITreeNodePath path)
        {
            if (path == null)
            {
                return(null);
            }

            if (path.IsEqual(Path))
            {
                return(this);
            }

            foreach (ISolutionTreeNode Child in Children)
            {
                if (path.IsEqual(Child.Path))
                {
                    return(Child);
                }

                ISolutionFolder AsFolder;
                if ((AsFolder = Child as ISolutionFolder) != null)
                {
                    ISolutionTreeNode TreeNode = AsFolder.FindTreeNode(path);
                    if (TreeNode != null)
                    {
                        return(TreeNode);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        string NodeToString(ISolutionTreeNode node)
        {
            var stringBuilder = new System.Text.StringBuilder();

            nodePrinter(stringBuilder, node);

            return(stringBuilder.ToString());
        }
Пример #3
0
        string NodeToString (ISolutionTreeNode node)
        {
            var stringBuilder = new System.Text.StringBuilder ();

            nodePrinter (stringBuilder, node);

            return stringBuilder.ToString ();
        }
Пример #4
0
        private void ChangeName(string Name)
        {
            ISolutionTreeNode Node = Root.FindTreeNode(Path);

            Assert.CheckCondition(Node != null);

            Node.ChangeName(Name);
        }
Пример #5
0
 public static void PrintDcgNode (System.Text.StringBuilder stringBuilder, ISolutionTreeNode node)
 {
     Goal goal = node.HeadGoal;
     string predicate = goal.Definition.Predicate.Name;
     if (predicate != "concat")
     {
         stringBuilder.Append (predicate);
         stringBuilder.Append ("(");
         stringBuilder.Append (string.Join(", ", goal.Arguments.Where(a => !(a.ConcreteValue is List)).Select (new ArgumentPrinter().Print)));
         stringBuilder.Append (")");
     }
 }
Пример #6
0
        public static void PrintDcgNode(System.Text.StringBuilder stringBuilder, ISolutionTreeNode node)
        {
            Goal   goal      = node.HeadGoal;
            string predicate = goal.Definition.Predicate.Name;

            if (predicate != "concat")
            {
                stringBuilder.Append(predicate);
                stringBuilder.Append("(");
                stringBuilder.Append(string.Join(", ", goal.Arguments.Where(a => !(a.ConcreteValue is List)).Select(new ArgumentPrinter().Print)));
                stringBuilder.Append(")");
            }
        }
Пример #7
0
        private void ChangeParent(ISolutionFolder oldParent, ISolutionFolder newParent)
        {
            ISolutionTreeNode Node = Root.FindTreeNode(Path);

            Assert.CheckCondition(Node != null);

            ISolutionTreeNodeCollection OldChildrenCollection = (ISolutionTreeNodeCollection)oldParent.Children;

            OldChildrenCollection.Remove(Node);

            ISolutionTreeNodeCollection NewChildrenCollection = (ISolutionTreeNodeCollection)newParent.Children;

            NewChildrenCollection.Add(Node);

            NewChildrenCollection.Sort();
        }
Пример #8
0
// ReSharper disable ParameterTypeCanBeEnumerable.Local
        private void SolutionTreeToString (ISolutionTreeNode solution, int level)
// ReSharper restore ParameterTypeCanBeEnumerable.Local
        {
            foreach (var node in solution)
            {
                string s = NodeToString (node);

                if (!string.IsNullOrWhiteSpace (s))
                {
                    sb.Append (new string (' ', level * 4));

                    sb.AppendLine (s);
                }

                SolutionTreeToString (node, level + 1);
            }
        }
Пример #9
0
// ReSharper disable ParameterTypeCanBeEnumerable.Local
        private void SolutionTreeToString(ISolutionTreeNode solution, int level)
// ReSharper restore ParameterTypeCanBeEnumerable.Local
        {
            foreach (var node in solution)
            {
                string s = NodeToString(node);

                if (!string.IsNullOrWhiteSpace(s))
                {
                    sb.Append(new string (' ', level * 4));

                    sb.AppendLine(s);
                }

                SolutionTreeToString(node, level + 1);
            }
        }
Пример #10
0
 public static void Print (System.Text.StringBuilder sb, ISolutionTreeNode frame)
 {
     Print (frame.HeadGoal, sb);
 }
Пример #11
0
 public static void Print(System.Text.StringBuilder sb, ISolutionTreeNode frame)
 {
     Print(frame.HeadGoal, sb);
 }
Пример #12
0
 public static string SolutionTreeToString (ISolutionTreeNode solution)
 {
     return new SolutionTreePrinter ().Print (solution);
 }
Пример #13
0
 static void PrintNode(System.Text.StringBuilder stringBuilder, ISolutionTreeNode node)
 {
     Print(stringBuilder, node);
 }
Пример #14
0
        public string Print (ISolutionTreeNode solution)
        {
            SolutionTreeToString (solution, 0);

            return sb.ToString ();
        }
Пример #15
0
 static void PrintNode (System.Text.StringBuilder stringBuilder, ISolutionTreeNode node)
 {
     Print (stringBuilder, node);
 }
Пример #16
0
 private static string Print(ISolutionTreeNode solution)
 {
     return(new SolutionTreePrinter(SolutionTreePrinter.PrintDcgNode).Print(solution));
 }
Пример #17
0
 public Enter(ISolutionTreeNode node)
 {
     this.node = node;
 }
Пример #18
0
 public Leave (ISolutionTreeNode node)
 {
     this.node = node;
 }
Пример #19
0
 public Solution (ISolutionTreeNode tree)
 {
     this.tree = tree;
 }
Пример #20
0
 public Enter (ISolutionTreeNode node)
 {
     this.node = node;
 }
Пример #21
0
 public static string SolutionTreeToString(ISolutionTreeNode solution)
 {
     return(new SolutionTreePrinter().Print(solution));
 }
Пример #22
0
 public Solution(ISolutionTreeNode tree)
 {
     this.tree = tree;
 }
Пример #23
0
        public string Print(ISolutionTreeNode solution)
        {
            SolutionTreeToString(solution, 0);

            return(sb.ToString());
        }
Пример #24
0
 public Leave(ISolutionTreeNode node)
 {
     this.node = node;
 }
Пример #25
0
 private static string Print (ISolutionTreeNode solution)
 {
     return new SolutionTreePrinter (SolutionTreePrinter.PrintDcgNode).Print (solution);
 }