Beispiel #1
0
        /// <summary>
        /// Creates a persisted dictionary.
        /// </summary>
        /// <typeparam name="TKey">The type of keys stored in the dictionary.</typeparam>
        /// <typeparam name="TValue">The type of values stored in the dictionary.</typeparam>
        /// <param name="id">The identifier to use for the dictionary.</param>
        /// <returns>A new persisted dictionary instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">A persisted object with identifier <paramref name="id"/> already exists.</exception>
        public IPersistedDictionary <TKey, TValue> CreateDictionary <TKey, TValue>(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var set = new UnsortedDictionary(this);

            _items.Add(id, set);
            return(CreateDictionaryCore <TKey, TValue>(id, set));
        }
Beispiel #2
0
 /// <summary>
 /// Creates a statically typed wrapper around the specified <paramref name="dictionary"/>.
 /// </summary>
 /// <typeparam name="TKey">The type of keys stored in the dictionary.</typeparam>
 /// <typeparam name="TValue">The type of values stored in the dictionary.</typeparam>
 /// <param name="id">The identifier of the dictionary.</param>
 /// <param name="dictionary">The storage entity representing the dictionary</param>
 /// <returns>A statically typed wrapper around the specified <paramref name="dictionary"/>.</returns>
 private static IPersistedDictionary <TKey, TValue> CreateDictionaryCore <TKey, TValue>(string id, UnsortedDictionary dictionary) => dictionary.Create <TKey, TValue>(id);