Dictionaries.cs 523 B

12345678910111213141516
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Google.ProtocolBuffers.Collections {
  5. /// <summary>
  6. /// Non-generic class with generic methods which proxy to the non-generic methods
  7. /// in the generic class.
  8. /// </summary>
  9. public static class Dictionaries {
  10. public static IDictionary<TKey, TValue> AsReadOnly<TKey, TValue> (IDictionary<TKey, TValue> dictionary) {
  11. return dictionary.IsReadOnly ? dictionary : new ReadOnlyDictionary<TKey, TValue>(dictionary);
  12. }
  13. }
  14. }