Пример #1
0
 /// <summary>
 ///     Gets a read-only wrapper around this dictionary. If <paramref name="cache"/> is already a wrapper for this
 ///     dictionary returns that, otherwise creates a new wrapper, stores it in <paramref name="cache"/>, and returns
 ///     that.</summary>
 public static ReadOnlyDictionary <TK, TV> AsReadOnly <TK, TV>(this IDictionary <TK, TV> dict, ref ReadOnlyDictionary <TK, TV> cache)
 {
     if (dict == null)
     {
         throw new ArgumentNullException(nameof(dict));
     }
     if (cache == null || !cache.IsWrapperFor(dict))
     {
         cache = new ReadOnlyDictionary <TK, TV>(dict);
     }
     return(cache);
 }