Esempio n. 1
0
        private void TraverseTreeAndAddElementsByName(DeserializedElement element, List <DeserializedElement> list, string elementName)
        {
            if (element.Name == elementName)
            {
                list.Add(element);
            }

            foreach (var child in element.Children)
            {
                TraverseTreeAndAddElementsByName(child, list, elementName);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Serializes a single element.
        /// </summary>
        /// <param name="deserializedElement"></param>
        /// <returns>The serialized element</returns>
        public XElement SerializeElement(DeserializedElement deserializedElement)
        {
            XElement element = new XElement(deserializedElement.Name);

            foreach (var attribute in deserializedElement.Attributes)
            {
                element.SetAttributeValue(attribute.Key, attribute.Value);
            }


            foreach (var child in deserializedElement.Children)
            {
                element.Add(SerializeElement(child));
            }

            if (deserializedElement.Value != null)
            {
                element.Add(deserializedElement.Value);
            }



            return(element);
        }
Esempio n. 3
0
 /// <summary>
 /// Creates instance of DefaultSerializer
 /// </summary>
 /// <param name="root"></param>
 public DefaultSerializer(DeserializedElement root)
 {
     Root = root;
 }
        /// <summary>
        /// Deserializes the given .xml file into tree of DeserializedElement objects.
        /// </summary>
        public void Deserialize()
        {
            XElement root = Document.Root;

            Root = new DeserializedElement(root);
        }