Lucene.Net.Core.Support: Moved UnmodifiableDictionary to be a nested class of Compatibility.Collections and made it private
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/152c37e7 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/152c37e7 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/152c37e7 Branch: refs/heads/api-work Commit: 152c37e7201d96b23ead88dff6b0926753fe5646 Parents: 7d32477 Author: Shad Storhaug <[email protected]> Authored: Tue Jan 31 13:14:49 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Tue Jan 31 13:14:49 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Core/Lucene.Net.csproj | 1 - .../Support/Compatibility/Collections.cs | 108 ++++++++++++++++++ .../Support/UnmodifiableDictionary.cs | 109 ------------------- 3 files changed, 108 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/152c37e7/src/Lucene.Net.Core/Lucene.Net.csproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Lucene.Net.csproj b/src/Lucene.Net.Core/Lucene.Net.csproj index 4d0feb2..a4b4d24 100644 --- a/src/Lucene.Net.Core/Lucene.Net.csproj +++ b/src/Lucene.Net.Core/Lucene.Net.csproj @@ -666,7 +666,6 @@ <Compile Include="Support\TimeHelper.cs" /> <Compile Include="Support\TreeDictionary.cs" /> <Compile Include="Support\TreeSet.cs" /> - <Compile Include="Support\UnmodifiableDictionary.cs" /> <Compile Include="Support\CloseableThreadLocalProfiler.cs" /> <Compile Include="Support\Compatibility\ConcurrentDictionary.cs" /> <Compile Include="Support\Compatibility\Func.cs" /> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/152c37e7/src/Lucene.Net.Core/Support/Compatibility/Collections.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/Compatibility/Collections.cs b/src/Lucene.Net.Core/Support/Compatibility/Collections.cs index 729d526..bf421e9 100644 --- a/src/Lucene.Net.Core/Support/Compatibility/Collections.cs +++ b/src/Lucene.Net.Core/Support/Compatibility/Collections.cs @@ -378,6 +378,114 @@ namespace Lucene.Net #endregion ReverseComparer2 + #region UnmodifiableDictionary + + private class UnmodifiableDictionary<TKey, TValue> : IDictionary<TKey, TValue> + { + private IDictionary<TKey, TValue> _dict; + + public UnmodifiableDictionary(IDictionary<TKey, TValue> dict) + { + _dict = dict; + } + + public UnmodifiableDictionary() + { + _dict = new Dictionary<TKey, TValue>(); + } + + public void Add(TKey key, TValue value) + { + throw new InvalidOperationException("Unable to modify this dictionary."); + } + + public bool ContainsKey(TKey key) + { + return _dict.ContainsKey(key); + } + + public ICollection<TKey> Keys + { + get { return _dict.Keys; } + } + + public bool Remove(TKey key) + { + throw new InvalidOperationException("Unable to modify this dictionary."); + } + + public bool TryGetValue(TKey key, out TValue value) + { + return _dict.TryGetValue(key, out value); + } + + public ICollection<TValue> Values + { + get { return _dict.Values; } + } + + public TValue this[TKey key] + { + get + { + TValue ret; + _dict.TryGetValue(key, out ret); + return ret; + } + set + { + throw new InvalidOperationException("Unable to modify this dictionary."); + } + } + + public void Add(KeyValuePair<TKey, TValue> item) + { + throw new InvalidOperationException("Unable to modify this dictionary."); + } + + public void Clear() + { + throw new InvalidOperationException("Unable to modify this dictionary."); + } + + public bool Contains(KeyValuePair<TKey, TValue> item) + { + return _dict.Contains(item); + } + + public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) + { + _dict.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return _dict.Count; } + } + + public bool IsReadOnly + { + get { return true; } + } + + public bool Remove(KeyValuePair<TKey, TValue> item) + { + throw new InvalidOperationException("Unable to modify this dictionary."); + } + + public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() + { + return _dict.GetEnumerator(); + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return _dict.GetEnumerator(); + } + } + + #endregion UnmodifiableDictionary + #endregion Nested Types } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/152c37e7/src/Lucene.Net.Core/Support/UnmodifiableDictionary.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/UnmodifiableDictionary.cs b/src/Lucene.Net.Core/Support/UnmodifiableDictionary.cs deleted file mode 100644 index ccb2910..0000000 --- a/src/Lucene.Net.Core/Support/UnmodifiableDictionary.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Lucene.Net.Support -{ - internal class UnmodifiableDictionary<TKey, TValue> : IDictionary<TKey, TValue> - { - private IDictionary<TKey, TValue> _dict; - - public UnmodifiableDictionary(IDictionary<TKey, TValue> dict) - { - _dict = dict; - } - - public UnmodifiableDictionary() - { - _dict = new Dictionary<TKey, TValue>(); - } - - public void Add(TKey key, TValue value) - { - throw new InvalidOperationException("Unable to modify this dictionary."); - } - - public bool ContainsKey(TKey key) - { - return _dict.ContainsKey(key); - } - - public ICollection<TKey> Keys - { - get { return _dict.Keys; } - } - - public bool Remove(TKey key) - { - throw new InvalidOperationException("Unable to modify this dictionary."); - } - - public bool TryGetValue(TKey key, out TValue value) - { - return _dict.TryGetValue(key, out value); - } - - public ICollection<TValue> Values - { - get { return _dict.Values; } - } - - public TValue this[TKey key] - { - get - { - TValue ret; - _dict.TryGetValue(key, out ret); - return ret; - } - set - { - throw new InvalidOperationException("Unable to modify this dictionary."); - } - } - - public void Add(KeyValuePair<TKey, TValue> item) - { - throw new InvalidOperationException("Unable to modify this dictionary."); - } - - public void Clear() - { - throw new InvalidOperationException("Unable to modify this dictionary."); - } - - public bool Contains(KeyValuePair<TKey, TValue> item) - { - return _dict.Contains(item); - } - - public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) - { - _dict.CopyTo(array, arrayIndex); - } - - public int Count - { - get { return _dict.Count; } - } - - public bool IsReadOnly - { - get { return true; } - } - - public bool Remove(KeyValuePair<TKey, TValue> item) - { - throw new InvalidOperationException("Unable to modify this dictionary."); - } - - public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() - { - return _dict.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return _dict.GetEnumerator(); - } - } -} \ No newline at end of file
