/// <summary> /// Stores the specified database in cache. /// </summary> /// <param name="database">The dataabase to be cached.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="database"/> cannot be <c>null</c>. /// </exception> public void Cache(CachedDatabase database) { if (database == null) throw new ArgumentNullException("database"); Database = database; var groups = database.Document .Descendants("Group") .ToList(); Root = groups.FirstOrDefault(); _groups = groups.ToLookup(x => (string)x.Element("UUID")); _entries = groups .SelectMany(x => x.Elements("Entry")) .ToLookup(x => (string)x.Element("UUID")); }
/// <summary> /// Stores the specified database in cache. /// </summary> /// <param name="database">The dataabase to be cached.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="database"/> cannot be <c>null</c>. /// </exception> public void Cache(CachedDatabase database) { if (database == null) { throw new ArgumentNullException("database"); } Database = database; var groups = database.Document .Descendants("Group") .ToList(); Root = groups.FirstOrDefault(); _groups = groups.ToLookup(x => (string)x.Element("UUID")); _entries = groups .SelectMany(x => x.Elements("Entry")) .ToLookup(x => (string)x.Element("UUID")); }
public void Cache(CachedDatabase database) { throw new NotSupportedException(); }
public void Should_provides_the_cached_database() { var db = new CachedDatabase { Document = new XDocument() }; _service.Cache(db); Assert.Same(db, _service.Database); }