Exemplo n.º 1
0
        public ISetup Clone()
        {
            SetupFolder folder = new SetupFolder();

            folder.Name = Name;
            folder.Icon = Icon;
            foreach (ISetup entry in Entries)
            {
                folder.Entries.Add(entry.Clone());
            }
            return(folder);
        }
Exemplo n.º 2
0
        //=========== LOADING ============
        #region Loading

        public void Read <T>(XmlElement folder) where T : Setup
        {
            XmlNode    node;
            XmlElement element;

            Entries.Clear();

            if (Parent != null)
            {
                node = folder.SelectSingleNode("Name");
                if (node != null)
                {
                    Name = node.InnerText;
                }

                node = folder.SelectSingleNode("Details");
                if (node != null)
                {
                    Details = node.InnerText;
                }

                node = folder.SelectSingleNode("Icon");
                if (node != null)
                {
                    Icon = node.InnerText;
                }
            }

            foreach (XmlNode folderNode in folder)
            {
                element = folderNode as XmlElement;
                if (element != null)
                {
                    if (element.Name == "Folder")
                    {
                        SetupFolder subFolder = new SetupFolder(this);
                        subFolder.Read <T>(element);
                        Entries.Add(subFolder);
                    }
                    else if (element.Name == typeof(T).Name)
                    {
                        Setup setup = Activator.CreateInstance <T>();
                        setup.Read(element);
                        Entries.Add(setup);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Write <T>(XmlElement folder, XmlDocument doc)
        {
            XmlElement element;

            if (Parent != null)
            {
                element = doc.CreateElement("Name");
                element.AppendChild(doc.CreateTextNode(Name));
                folder.AppendChild(element);

                element = doc.CreateElement("Details");
                element.AppendChild(doc.CreateTextNode(Details));
                folder.AppendChild(element);

                element = doc.CreateElement("Icon");
                element.AppendChild(doc.CreateTextNode(Icon));
                folder.AppendChild(element);
            }

            foreach (ISetup entry in Entries)
            {
                if (entry is SetupFolder)
                {
                    SetupFolder subFolder        = (SetupFolder)entry;
                    XmlElement  subFolderElement = doc.CreateElement("Folder");
                    subFolder.Write <T>(subFolderElement, doc);
                    folder.AppendChild(subFolderElement);
                }
                else if (entry is Setup)
                {
                    Setup      setup        = (Setup)entry;
                    XmlElement setupElement = doc.CreateElement(typeof(T).Name);
                    setup.Write(setupElement, doc);
                    folder.AppendChild(setupElement);
                }
            }
        }
Exemplo n.º 4
0
 public SetupFolder(SetupFolder parent)
 {
     Parent = parent;
 }