Beispiel #1
0
        /// <summary>
        /// Read shape from XML stream and return it.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="parent"></param>
        /// <param name="umlType"></param>
        /// <returns></returns>
        public static UmlNoteShapeViewModel ReadDocument(XmlReader reader,
                                                         IShapeParent parent,
                                                         UmlTypes umlType)
        {
            UmlNoteShapeViewModel ret = UmlElementDataDef.CreateShape(umlType, new System.Windows.Point(UmlTypeToStringConverter.DefaultX,
                                                                                                        UmlTypeToStringConverter.DefaultY), parent)
                                        as UmlNoteShapeViewModel;

            reader.ReadToNextSibling(ret.UmlDataTypeString);

            while (reader.MoveToNextAttribute())
            {
                if (ret.ReadAttributes(reader.Name, reader.Value) == false)
                {
                    if (reader.Name.Trim().Length > 0 && reader.Name != UmlShapeBaseViewModel.XmlComment)
                    {
                        throw new ArgumentException("XML node:'" + reader.Name + "' as child of '" + ret.XElementName + "' is not supported.");
                    }
                }
            }

            // Read child elements of this XML node
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    string nodeName = reader.Name;
                    string error;

                    if ((error = ret.ReadXMLNode(nodeName, reader)) != string.Empty)
                    {
                        throw new NotImplementedException(error);
                    }
                }
            }

            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Persist the contents of this object into the given
        /// parameter <paramref name="writer"/> object.
        /// </summary>
        /// <param name="writer"></param>
        public override void SaveDocument(System.Xml.XmlWriter writer,
                                          IEnumerable <ShapeViewModelBase> root)
        {
            writer.WriteStartElement(this.mElementName);

            this.SaveAttributes(writer);

            // Save common model information (eg. comments)
            base.SaveDocument(writer);

            // Write text string as content of text tag
            UmlNoteShapeViewModel.SaveTextDocument(writer, this.Text);

            if (root != null)
            {
                foreach (var item in root)
                {
                    item.SaveDocument(writer, item.Elements());
                }
            }

            writer.WriteEndElement();
        }