Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PathFigureCollectionConverter.cs
- FusionWrap.cs
- StructuredTypeInfo.cs
- DataGridItem.cs
- ConfigsHelper.cs
- SendReply.cs
- Int32RectConverter.cs
- SkinBuilder.cs
- DataObjectFieldAttribute.cs
- DataListItemCollection.cs
- SafeNativeMethodsCLR.cs
- ScalarConstant.cs
- PopupRootAutomationPeer.cs
- ToolboxComponentsCreatingEventArgs.cs
- ObfuscateAssemblyAttribute.cs
- EmissiveMaterial.cs
- Grid.cs
- ActivityMarkupSerializationProvider.cs
- ContextMenu.cs
- ISCIIEncoding.cs
- OdbcParameterCollection.cs
- SqlError.cs
- PopOutPanel.cs
- StyleCollection.cs
- Misc.cs
- DataList.cs
- ObservableDictionary.cs
- OleDbPropertySetGuid.cs
- SpecialTypeDataContract.cs
- CounterSampleCalculator.cs
- SponsorHelper.cs
- DBConcurrencyException.cs
- NullableIntMinMaxAggregationOperator.cs
- Cursors.cs
- While.cs
- AutoSizeToolBoxItem.cs
- ObjectDataSourceDesigner.cs
- CustomAssemblyResolver.cs
- DropSourceBehavior.cs
- ContentWrapperAttribute.cs
- ExtendedProtectionPolicyElement.cs
- HtmlLink.cs
- SettingsProviderCollection.cs
- LocalizationParserHooks.cs
- HttpWrapper.cs
- RootBuilder.cs
- RichTextBoxAutomationPeer.cs
- SectionUpdates.cs
- GridViewRowEventArgs.cs
- PropertyCondition.cs
- DataTableCollection.cs
- TemplatedControlDesigner.cs
- TableAutomationPeer.cs
- EnumType.cs
- Debugger.cs
- GenericTypeParameterConverter.cs
- HttpConfigurationContext.cs
- GroupStyle.cs
- DictionaryGlobals.cs
- MetadataException.cs
- ScrollViewerAutomationPeer.cs
- ArithmeticException.cs
- HeaderUtility.cs
- columnmapfactory.cs
- EventDescriptorCollection.cs
- SqlWebEventProvider.cs
- TextEditorParagraphs.cs
- Bidi.cs
- AuthorizationSection.cs
- ImageMapEventArgs.cs
- BaseCollection.cs
- MarkedHighlightComponent.cs
- MetadataUtilsSmi.cs
- PointLight.cs
- CachedTypeface.cs
- _ServiceNameStore.cs
- TimelineClockCollection.cs
- Normalizer.cs
- CacheSection.cs
- WorkflowInstanceExtensionManager.cs
- Setter.cs
- OracleColumn.cs
- LoginName.cs
- DayRenderEvent.cs
- UdpConstants.cs
- SingleConverter.cs
- UnsafeNativeMethods.cs
- PrintDocument.cs
- HitTestParameters3D.cs
- PageStatePersister.cs
- XmlTextReader.cs
- HtmlTextArea.cs
- Walker.cs
- ELinqQueryState.cs
- EntityDataSourceValidationException.cs
- TrustManagerMoreInformation.cs
- DataGridViewRowCollection.cs
- MessageHeaderInfoTraceRecord.cs
- CodeDelegateCreateExpression.cs
- ExpandoObject.cs