From 3783d9a8add33b240e326438fa0b16869dbcfb44 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 29 Jul 2015 16:05:57 -0700 Subject: remove the freeze API --- csharp/src/Google.Protobuf/Collections/MapField.cs | 34 ++-------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'csharp/src/Google.Protobuf/Collections/MapField.cs') diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 68f2f1cc..0f7227c2 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -50,7 +50,7 @@ namespace Google.Protobuf.Collections /// /// Key type in the map. Must be a type supported by Protocol Buffer map keys. /// Value type in the map. Must be a type supported by Protocol Buffers. - public sealed class MapField : IDeepCloneable>, IFreezable, IDictionary, IEquatable>, IDictionary + public sealed class MapField : IDeepCloneable>, IDictionary, IEquatable>, IDictionary { // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) private readonly bool allowNullValues; @@ -119,7 +119,6 @@ namespace Google.Protobuf.Collections public bool Remove(TKey key) { - this.CheckMutable(); ThrowHelper.ThrowIfNull(key, "key"); LinkedListNode> node; if (map.TryGetValue(key, out node)) @@ -169,7 +168,6 @@ namespace Google.Protobuf.Collections { ThrowHelper.ThrowIfNull(value, "value"); } - this.CheckMutable(); LinkedListNode> node; var pair = new KeyValuePair(key, value); if (map.TryGetValue(key, out node)) @@ -214,7 +212,6 @@ namespace Google.Protobuf.Collections public void Clear() { - this.CheckMutable(); list.Clear(); map.Clear(); } @@ -233,7 +230,6 @@ namespace Google.Protobuf.Collections bool ICollection>.Remove(KeyValuePair item) { - this.CheckMutable(); if (item.Key == null) { throw new ArgumentException("Key is null", "item"); @@ -260,31 +256,6 @@ namespace Google.Protobuf.Collections public int Count { get { return list.Count; } } public bool IsReadOnly { get { return frozen; } } - public void Freeze() - { - if (IsFrozen) - { - return; - } - frozen = true; - // Only values can be frozen, as all the key types are simple. - // Everything can be done in-place, as we're just freezing objects. - if (typeof(IFreezable).IsAssignableFrom(typeof(TValue))) - { - for (var node = list.First; node != null; node = node.Next) - { - var pair = node.Value; - IFreezable freezableValue = pair.Value as IFreezable; - if (freezableValue != null) - { - freezableValue.Freeze(); - } - } - } - } - - public bool IsFrozen { get { return frozen; } } - public override bool Equals(object other) { return Equals(other as MapField); @@ -405,7 +376,6 @@ namespace Google.Protobuf.Collections void IDictionary.Remove(object key) { ThrowHelper.ThrowIfNull(key, "key"); - this.CheckMutable(); if (!(key is TKey)) { return; @@ -420,7 +390,7 @@ namespace Google.Protobuf.Collections temp.CopyTo(array, index); } - bool IDictionary.IsFixedSize { get { return IsFrozen; } } + bool IDictionary.IsFixedSize { get { return false; } } ICollection IDictionary.Keys { get { return (ICollection)Keys; } } -- cgit v1.2.3