Imported Upstream version 3.8.0

Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
Jo Shields
2014-09-04 09:07:35 +01:00
parent a575963da9
commit fe777c5c82
1062 changed files with 12460 additions and 5983 deletions

View File

@@ -1,106 +0,0 @@
// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Internal;
// This is using the desktop namespace for ReadOnlyDictionary, the source code is in Microsoft\Internal\Collections to keep it seperate from the main MEF codebase.
namespace System.Collections.ObjectModel
{
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(ReadOnlyDictionaryDebuggerProxy<,>))]
internal sealed partial class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{
private readonly IDictionary<TKey, TValue> _innerDictionary;
public ReadOnlyDictionary(IDictionary<TKey, TValue> dictionary)
{
this._innerDictionary = dictionary ?? new Dictionary<TKey, TValue>(0);
}
public int Count
{
get { return this._innerDictionary.Count; }
}
public bool IsReadOnly
{
get { return true; }
}
public ICollection<TKey> Keys
{
get { return this._innerDictionary.Keys; }
}
public TValue this[TKey key]
{
get { return this._innerDictionary[key]; }
set { throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary); }
}
public ICollection<TValue> Values
{
get { return this._innerDictionary.Values; }
}
public bool Contains(KeyValuePair<TKey, TValue> item)
{
return this._innerDictionary.Contains(item);
}
public bool ContainsKey(TKey key)
{
return this._innerDictionary.ContainsKey(key);
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
this._innerDictionary.CopyTo(array, arrayIndex);
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return this._innerDictionary.GetEnumerator();
}
public bool TryGetValue(TKey key, out TValue value)
{
return this._innerDictionary.TryGetValue(key, out value);
}
IEnumerator IEnumerable.GetEnumerator()
{
return this._innerDictionary.GetEnumerator();
}
void IDictionary<TKey, TValue>.Add(TKey key, TValue value)
{
throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);
}
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
{
throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);
}
void ICollection<KeyValuePair<TKey, TValue>>.Clear()
{
throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);
}
bool IDictionary<TKey, TValue>.Remove(TKey key)
{
throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);
}
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
{
throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);
}
}
}

View File

@@ -1,34 +0,0 @@
// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.Internal;
namespace System.Collections.ObjectModel
{
// NOTE: This type cannot be a nested proxy of ReadOnlyDictionary due to a bug
// in the Visual Studio Debugger which causes it to ignore nested generic proxies.
internal class ReadOnlyDictionaryDebuggerProxy<TKey, TValue>
{
private readonly ReadOnlyDictionary<TKey, TValue> _dictionary;
public ReadOnlyDictionaryDebuggerProxy(ReadOnlyDictionary<TKey, TValue> dictionary)
{
Requires.NotNull(dictionary, "dictionary");
_dictionary = dictionary;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public KeyValuePair<TKey, TValue>[] Items
{
// NOTE: This shouldn't be cached, so that on every query of
// the current value of the underlying dictionary is respected.
get { return this._dictionary.ToArray(); }
}
}
}