示例#1
0
        protected ElementoTemplate CaricaTemplate(String path)
        {
            if (path == null)
            {
                throw new InvalidDataException();
            }
            //if (!Directory.Exists(path)) throw new IOException();
            //if (!File.Exists(path + "/Template.xml")) throw new IOException();
            ElementoTemplate root = new Contenitore("root");

            try { root = Documento.GetIstance().Persister.LoadTemplate(path + "/Template.xml"); }
            catch { Documento.GetIstance().Persister.SaveTemplate(path + "/Template.xml", root); }
            return(root);
        }
示例#2
0
 private void SaveContenitore(Contenitore contenitore)
 {
     _writer.WriteStartElement("Contenitore");
     _writer.WriteAttributeString("name", contenitore.Id);
     foreach (ElementoTemplate child in contenitore.Children)
     {
         if (child is Contenuto)
         {
             SaveContenuto((Contenuto)child);
         }
         else if (child is Contenitore)
         {
             SaveContenitore((Contenitore)child);
         }
     }
     _writer.WriteEndElement();
 }
示例#3
0
        private ElementoTemplate LoadContenitore(XmlElement contenitore)
        {
            string      nome   = contenitore.GetAttribute("name");
            Contenitore parent = new Contenitore(nome);

            foreach (XmlElement child in contenitore.ChildNodes)
            {
                if (child.LocalName == "Contenitore")
                {
                    LoadContenitore(child).Parent = parent;
                }
                else if (child.LocalName == "Contenuto")
                {
                    LoadContenuto(child).Parent = parent;
                }
                else
                {
                    throw new IOException();
                }
            }
            return(parent);
        }