private void ImportFolders(XmlDocument doc) { foreach (XmlNode node in doc.SelectNodes("/database/folders/folder")) { XmlAttribute attrName = node.Attributes["name"]; XmlAttribute attrCat = node.Attributes["category"]; if (attrCat != null && attrName != null) { Folder folder = this.database.Folders.Create(attrName.Value, attrCat.Value); XmlAttribute attr; foreach (XmlNode classNode in node.SelectNodes("classes/class")) { attr = classNode.Attributes["guid"]; if (attr != null) { folder.AddClass(this.database.Classes[new Guid(attr.Value)]); } } XmlNode grp = node.SelectSingleNode("group"); attr = grp.Attributes["method"]; folder.GroupMethod = attr == null ? 0 : int.Parse(attr.Value); attr = grp.Attributes["class_id"]; if (attr != null) { ObjectClass objectClass = this.database.Classes[new Guid(attr.Value)]; if (objectClass != null) { attr = grp.Attributes["field"]; if (attr != null) { Field field = objectClass[attr.Value]; folder.Group = field; } } } if (folder.Group == null && folder.GroupMethod > 0) { folder.GroupMethod = 0; } this.database.Folders.Update(folder); } } }