コード例 #1
0
        /// <summary>
        /// Serializes the given shape to xml
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        private NodeType SerializeNode(ShapeBase s)
        {
            Hashtable attributes = GraphDataAttribute.GetValuesOfTaggedFields(s);

            NodeType node = new NodeType();

            //node.ID = FormatID(s);

            //node.Items.Add(DataTypeFromEntity(s));

            if (typeof(OvalShape).IsInstanceOfType(s))
            {
                node.Type = "Netron.Lithium.OvalShape";
            }
            else if (typeof(SimpleRectangle).IsInstanceOfType(s))
            {
                node.Type = "Netron.Lithium.SimpleRectangle";
            }
            else if (typeof(TextLabel).IsInstanceOfType(s))
            {
                node.Type = "Netron.Lithium.TextLabel";
            }

            foreach (DataType data in DataTypesFromAttributes(attributes))
            {
                node.Items.Add(data);
            }

            return(node);
        }
コード例 #2
0
        /// <summary>
        /// Serializes a diagram edge
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        private EdgeType SerializeEdge(Connection c)
        {
            Hashtable attributes = GraphDataAttribute.GetValuesOfTaggedFields(c);

            EdgeType edge = new EdgeType();

            //edge.Source = c.From.Text;
            //edge.Target = c.To.Text;
            edge.From = c.From.UID.ToString();
            edge.To   = c.To.UID.ToString();
            //since there is only one type of edge we don't need the next one
            //edge.Data.Add(DataTypeFromEntity(c));

            foreach (DataType dt in DataTypesFromAttributes(attributes))
            {
                edge.Data.Add(dt);
            }

            return(edge);
        }