public static void Serialize(XmlWriter w, IKvaSerializable drawing, SerializationFilter filter)
        {
            if (drawing.Id == Guid.Empty)
            {
                return;
            }

            // The XML name for this drawing should be stored in its [XMLType] C# attribute.
            Type t = drawing.GetType();

            object[] attributes = t.GetCustomAttributes(typeof(XmlTypeAttribute), false);

            if (attributes.Length == 0)
            {
                return;
            }

            string xmlName = ((XmlTypeAttribute)attributes[0]).TypeName;

            w.WriteStartElement(xmlName);
            w.WriteAttributeString("id", drawing.Id.ToString());
            w.WriteAttributeString("name", drawing.Name);
            drawing.WriteXml(w, filter);
            w.WriteEndElement();
        }
Beispiel #2
0
        public void WriteXml(XmlWriter w)
        {
            w.WriteStartElement("Position");
            string userTime = m_ParentMetadata.TimeStampsToTimecode(m_Position, TimeCodeFormat.Unknown, false);

            w.WriteAttributeString("UserTime", userTime);
            w.WriteString(m_Position.ToString());
            w.WriteEndElement();

            if (!string.IsNullOrEmpty(Title))
            {
                w.WriteElementString("Title", Title);
            }

            if (!string.IsNullOrEmpty(m_CommentRtf))
            {
                w.WriteElementString("Comment", m_CommentRtf);
            }

            if (m_Drawings.Count > 0)
            {
                w.WriteStartElement("Drawings");
                foreach (AbstractDrawing drawing in m_Drawings)
                {
                    IKvaSerializable serializableDrawing = drawing as IKvaSerializable;
                    if (serializableDrawing != null)
                    {
                        // The XML name for this drawing should be stored in its [XMLType] C# attribute.
                        Type     t          = serializableDrawing.GetType();
                        object[] attributes = t.GetCustomAttributes(typeof(XmlTypeAttribute), false);

                        if (attributes.Length > 0)
                        {
                            string xmlName = ((XmlTypeAttribute)attributes[0]).TypeName;

                            w.WriteStartElement(xmlName);
                            serializableDrawing.WriteXml(w);
                            w.WriteEndElement();
                        }
                    }
                }
                w.WriteEndElement();
            }
        }