Beispiel #1
0
        /// <summary>
        ///  Build the Xml and send it.
        ///  It examined whether the tree cycles contains.
        ///  If the Client terminated, since this is not permitted
        /// </summary>
        public void Display()
        {
            if (CheckForCycles())
            {
                document = new XmlDocument();
                var dec = document.CreateXmlDeclaration("1.0", null, null);
                dec.Encoding = Encoding.UTF8.ToString();
                document.AppendChild(dec);
                var root = document.CreateElement(ROOT);
                document.AppendChild(root);


                var tree = document.CreateElement(TREE);
                root.AppendChild(tree);
                tree.SetAttribute(ATTRIBUTEID, this.gvsTreeId.ToString());

                var treeLabel = document.CreateElement(LABEL);
                tree.AppendChild(treeLabel);
                treeLabel.AppendChild(document.CreateTextNode(this.gvsTreeName));

                var nodes = document.CreateElement(NODES);
                root.AppendChild(nodes);


                foreach (GVSTreeNode node in gvsTreeNodes)
                {
                    var interfaces = node.GetType().GetInterfaces();
                    foreach (var theInterface in interfaces)
                    {
                        if (theInterface.FullName == typeof(GVSBinaryTreeNode).FullName)
                        {
                            var theNode = (GVSBinaryTreeNode)node;
                            if (theNode != null)
                            {
                                BuildBinaryNode(nodes, theNode);
                            }
                            else
                            {
                                //Trace
                            }
                            break;
                        }

                        /*else if(theInterface.FullName==typeof(GVSDefaultTreeNode).FullName){
                         *      GVSDefaultTreeNode theNode =(GVSDefaultTreeNode)node;
                         *      if(theNode!=null){
                         *              buildDefaultNode(nodes,theNode);
                         *      }
                         *      else{
                         *      }
                         *      break;
                         * }		   */
                    }
                }
                document.Save(Console.Out);
                xmlConnection.sendFile(document);
            }
        }
        /// <summary>
        /// Build the tree and check for cycles.
        /// If the tree is ok, it will be send to the server
        /// </summary>
        public void Display()
        {
            document = new XmlDocument();
            var dec = document.CreateXmlDeclaration("1.0", null, null);

            dec.Encoding = Encoding.UTF8.ToString();
            document.AppendChild(dec);
            var root = document.CreateElement(ROOT);

            document.AppendChild(root);


            var tree = document.CreateElement(TREE);

            root.AppendChild(tree);
            tree.SetAttribute(ATTRIBUTEID, this.gvsTreeId.ToString());

            var treeLabel = document.CreateElement(LABEL);

            tree.AppendChild(treeLabel);
            treeLabel.AppendChild(document.CreateTextNode(this.gvsTreeName));

            if (this.gvsTreeRoot != null)
            {
                var treeRoot = document.CreateElement(TREEROOTID);
                tree.AppendChild(treeRoot);
                treeRoot.AppendChild(document.CreateTextNode(this.gvsTreeRoot.GetHashCode().ToString()));

                var nodes = document.CreateElement(NODES);
                root.AppendChild(nodes);
                BuildNode(nodes, this.gvsTreeRoot);
            }
            else
            {
                Console.WriteLine("Kein Root deklariert");
            }

            if (!CheckForCycles())
            {
                document.Save(Console.Out);
                xmlConnection.sendFile(document);
            }
            else
            {
                Console.WriteLine("Baum enthält Zyklen. Kein senden erlaubt");
            }
        }
Beispiel #3
0
        /// <summary>
        ///	 Build the Xml and send it to the GVSServer
        /// </summary>
        public void Display()
        {
            document = new XmlDocument();
            var dec = document.CreateXmlDeclaration("1.0", null, null);

            dec.Encoding = Encoding.UTF8.ToString();
            document.AppendChild(dec);
            var root = document.CreateElement(ROOT);

            document.AppendChild(root);

            var graph = document.CreateElement(GRAPH);

            root.AppendChild(graph);
            graph.SetAttribute(ATTRIBUTEID, this.gvsGraphId.ToString());

            var graphLabel = document.CreateElement(LABEL);

            graph.AppendChild(graphLabel);
            graphLabel.AppendChild(document.CreateTextNode(this.gvsGraphName));

            var vertizes = document.CreateElement(VERTIZES);

            root.AppendChild(vertizes);

            foreach (var vertex in gvsGraphVertizes)
            {
                var interfaces = vertex.GetType().GetInterfaces();
                foreach (var theInterface in interfaces)
                {
                    if (theInterface.FullName == typeof(GVSRelativeVertex).FullName)
                    {
                        BuildRelativVertex(vertizes, (GVSRelativeVertex)vertex);
                        break;
                    }
                    else if (theInterface.FullName == typeof(GVSDefaultVertex).FullName)
                    {
                        BuildDefaultVertex(vertizes, (GVSDefaultVertex)vertex);
                    }
                }
            }

            var edges = document.CreateElement(EDGES);

            root.AppendChild(edges);

            foreach (var edge in gvsGraphEdges)
            {
                var interfaces = edge.GetType().GetInterfaces();
                foreach (var theInterface in interfaces)
                {
                    if (theInterface.FullName == typeof(GVSDirectedEdge).FullName)
                    {
                        BuildDirectedEdge(edges, (GVSDirectedEdge)edge);
                        break;
                    }
                    else if (theInterface.FullName == typeof(GVSUndirectedEdge).FullName)
                    {
                        BuildUndirectedEdge(edges, (GVSUndirectedEdge)edge);
                        break;
                    }
                }
            }

            xmlConnection.sendFile(document);
        }