private Group GetGroup(Database database) { string groupId; var queries = NavigationContext.QueryString; if (queries.TryGetValue("id", out groupId)) return database.GetGroup(groupId); _cmdHome.IsEnabled = false; return database.Root; }
public Database Parse() { var settings = new XmlReaderSettings { CloseInput = false, IgnoreComments = true, IgnoreWhitespace = true, IgnoreProcessingInstructions = true, }; using (var reader = XmlReader.Create(_stream, settings)) { if (!reader.ReadToFollowing("KeePassFile")) return null; if (!reader.ReadToDescendant("Meta")) return null; string recycleBinId = null; var icons = new Dictionary<string, ImageSource>(); using (var subReader = reader.ReadSubtree()) { subReader.ReadToFollowing("Generator"); while (!string.IsNullOrEmpty(subReader.Name)) { subReader.Skip(); switch (subReader.Name) { case "RecycleBinUUID": recycleBinId = subReader .ReadElementContentAsString(); break; case "CustomIcons": ParseIcons(subReader, _dispatcher, icons); break; } } } if (reader.Name != "Root" && !reader.ReadToNextSibling("Root")) { return null; } if (!reader.ReadToDescendant("Group")) return null; using (var subReader = reader.ReadSubtree()) { var root = ParseGroup(subReader); var database = new Database(root, icons); if (!string.IsNullOrEmpty(recycleBinId)) { database.RecycleBin = database .GetGroup(recycleBinId); } return database; } } }