Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Hosting / ReadOnlyDictionary.cs / 1305376 / ReadOnlyDictionary.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: ReadOnlyDictionary ** A wrapper on a Dictionary that throws if any of the ** write methods or property setters are called. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; namespace System.Collections.ObjectModel { [Serializable] internal class ReadOnlyDictionary: IDictionary { private IDictionary m_dictionary; public ReadOnlyDictionary(IDictionary dictionary) { if (dictionary == null) throw new ArgumentNullException("dictionary"); System.Diagnostics.Contracts.Contract.EndContractBlock(); m_dictionary = dictionary; } public void Add(TKey key, TValue value) { throw new NotSupportedException(); } public bool ContainsKey(TKey key) { return m_dictionary.ContainsKey(key); } public bool Remove(TKey key) { throw new NotSupportedException(); } public bool TryGetValue(TKey key, out TValue value) { return m_dictionary.TryGetValue(key, out value); } public TValue this[TKey key] { get { return m_dictionary[key]; } set { throw new NotSupportedException(); } } public ICollection Keys { get { return m_dictionary.Keys; } } public ICollection Values { get { return m_dictionary.Values; } } public void Add(KeyValuePair pair) { throw new NotSupportedException(); } public void Clear() { throw new NotSupportedException(); } public bool Contains(KeyValuePair keyValuePair) { return m_dictionary.Contains(keyValuePair); } public void CopyTo(KeyValuePair [] array, Int32 arrayIndex) { m_dictionary.CopyTo(array, arrayIndex); } public bool Remove(KeyValuePair keyValuePair) { throw new NotSupportedException(); } public IEnumerator > GetEnumerator() { return m_dictionary.GetEnumerator(); } public Int32 Count { get { return m_dictionary.Count; } } public bool IsReadOnly { get { return true; } } IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: ReadOnlyDictionary ** A wrapper on a Dictionary that throws if any of the ** write methods or property setters are called. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; namespace System.Collections.ObjectModel { [Serializable] internal class ReadOnlyDictionary : IDictionary { private IDictionary m_dictionary; public ReadOnlyDictionary(IDictionary dictionary) { if (dictionary == null) throw new ArgumentNullException("dictionary"); System.Diagnostics.Contracts.Contract.EndContractBlock(); m_dictionary = dictionary; } public void Add(TKey key, TValue value) { throw new NotSupportedException(); } public bool ContainsKey(TKey key) { return m_dictionary.ContainsKey(key); } public bool Remove(TKey key) { throw new NotSupportedException(); } public bool TryGetValue(TKey key, out TValue value) { return m_dictionary.TryGetValue(key, out value); } public TValue this[TKey key] { get { return m_dictionary[key]; } set { throw new NotSupportedException(); } } public ICollection Keys { get { return m_dictionary.Keys; } } public ICollection Values { get { return m_dictionary.Values; } } public void Add(KeyValuePair pair) { throw new NotSupportedException(); } public void Clear() { throw new NotSupportedException(); } public bool Contains(KeyValuePair keyValuePair) { return m_dictionary.Contains(keyValuePair); } public void CopyTo(KeyValuePair [] array, Int32 arrayIndex) { m_dictionary.CopyTo(array, arrayIndex); } public bool Remove(KeyValuePair keyValuePair) { throw new NotSupportedException(); } public IEnumerator > GetEnumerator() { return m_dictionary.GetEnumerator(); } public Int32 Count { get { return m_dictionary.Count; } } public bool IsReadOnly { get { return true; } } IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeCompiler.cs
- AQNBuilder.cs
- FlowDocumentPage.cs
- EventArgs.cs
- DocumentPageHost.cs
- PerformanceCounterManager.cs
- CharEntityEncoderFallback.cs
- MergeFilterQuery.cs
- OleDbException.cs
- InheritanceContextChangedEventManager.cs
- AsyncWaitHandle.cs
- OleDbError.cs
- ProcessThreadCollection.cs
- StringUtil.cs
- StringReader.cs
- CountdownEvent.cs
- XmlSerializer.cs
- UdpSocket.cs
- ReceiveErrorHandling.cs
- UnsafeNativeMethods.cs
- MetabaseReader.cs
- AxDesigner.cs
- ManagedIStream.cs
- OlePropertyStructs.cs
- LinkedList.cs
- ContextDataSource.cs
- SqlTransaction.cs
- SmiXetterAccessMap.cs
- ImageSource.cs
- SqlDataSourceCache.cs
- WebPartExportVerb.cs
- HuffModule.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ItemMap.cs
- IQueryable.cs
- MultipleViewProviderWrapper.cs
- UnsafeNativeMethods.cs
- HttpWriter.cs
- HostingEnvironmentSection.cs
- DefaultCommandExtensionCallback.cs
- MethodMessage.cs
- GiveFeedbackEventArgs.cs
- Graphics.cs
- PartManifestEntry.cs
- SimpleMailWebEventProvider.cs
- JavaScriptSerializer.cs
- AdCreatedEventArgs.cs
- OleDbDataAdapter.cs
- ResourceProperty.cs
- UITypeEditor.cs
- WinFormsSpinner.cs
- TargetControlTypeAttribute.cs
- ItemsControl.cs
- WebBaseEventKeyComparer.cs
- WebControl.cs
- ByteRangeDownloader.cs
- Marshal.cs
- FieldBuilder.cs
- PropertyGridCommands.cs
- PackageRelationshipSelector.cs
- IssuedSecurityTokenProvider.cs
- URLIdentityPermission.cs
- RenderDataDrawingContext.cs
- TextTrailingWordEllipsis.cs
- CommittableTransaction.cs
- SettingsSavedEventArgs.cs
- XamlVector3DCollectionSerializer.cs
- PointValueSerializer.cs
- HttpProfileBase.cs
- ExplicitDiscriminatorMap.cs
- PriorityBindingExpression.cs
- WebPartDescription.cs
- IpcManager.cs
- EmptyControlCollection.cs
- ObjectViewListener.cs
- IsolatedStorage.cs
- UdpDiscoveryMessageFilter.cs
- ScrollItemProviderWrapper.cs
- ConfigurationPermission.cs
- CompilerScopeManager.cs
- WebDisplayNameAttribute.cs
- WebHttpSecurity.cs
- UnsafeNativeMethodsMilCoreApi.cs
- TimeoutValidationAttribute.cs
- EntityDataSourceUtil.cs
- WindowCollection.cs
- RawTextInputReport.cs
- ObjectList.cs
- _HeaderInfo.cs
- CounterCreationDataCollection.cs
- HTMLTagNameToTypeMapper.cs
- SecuritySessionSecurityTokenProvider.cs
- HttpTransportBindingElement.cs
- PrintPreviewControl.cs
- ProcessMonitor.cs
- GlyphShapingProperties.cs
- AgileSafeNativeMemoryHandle.cs
- QuadraticBezierSegment.cs
- SingleConverter.cs
- TemplateBamlTreeBuilder.cs