Ejemplo n.º 1
0
        /// <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"));
        }
Ejemplo n.º 2
0
        /// <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"));
        }
Ejemplo n.º 3
0
 public void Cache(CachedDatabase database)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 4
0
        public void Should_provides_the_cached_database()
        {
            var db = new CachedDatabase
            {
                Document = new XDocument()
            };
            _service.Cache(db);

            Assert.Same(db, _service.Database);
        }