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
- EntityDataSourceColumn.cs
- Property.cs
- TreeNodeClickEventArgs.cs
- assemblycache.cs
- WindowsFormsHostPropertyMap.cs
- DockPatternIdentifiers.cs
- basecomparevalidator.cs
- EffectiveValueEntry.cs
- MarshalByValueComponent.cs
- ExistsInCollection.cs
- DataControlFieldTypeEditor.cs
- XmlSchemaExternal.cs
- MultipartIdentifier.cs
- ApplicationDirectoryMembershipCondition.cs
- CssStyleCollection.cs
- XmlConvert.cs
- WinFormsUtils.cs
- CfgSemanticTag.cs
- EntityStoreSchemaGenerator.cs
- QueryResult.cs
- BamlTreeUpdater.cs
- RowTypeElement.cs
- DesigntimeLicenseContext.cs
- MouseWheelEventArgs.cs
- EntityClassGenerator.cs
- AllMembershipCondition.cs
- _LocalDataStoreMgr.cs
- RawMouseInputReport.cs
- ClientSideQueueItem.cs
- ColorAnimationBase.cs
- MonthChangedEventArgs.cs
- MouseButtonEventArgs.cs
- SqlWorkflowPersistenceService.cs
- ConnectionManagementElementCollection.cs
- DiscoveryClientDocuments.cs
- CaseExpr.cs
- RoleBoolean.cs
- SqlClientFactory.cs
- ToolboxService.cs
- XLinq.cs
- XmlDeclaration.cs
- DataGridViewRowsAddedEventArgs.cs
- XmlConverter.cs
- ErrorStyle.cs
- Identity.cs
- TextBoxAutoCompleteSourceConverter.cs
- DbMetaDataFactory.cs
- RegexCompilationInfo.cs
- TextServicesDisplayAttribute.cs
- DataGridCellEditEndingEventArgs.cs
- DataSourceHelper.cs
- ResourcePermissionBaseEntry.cs
- XPathCompileException.cs
- MsmqDecodeHelper.cs
- StringResourceManager.cs
- CryptoApi.cs
- Vertex.cs
- IconConverter.cs
- DispatcherHooks.cs
- Math.cs
- MimeWriter.cs
- ReturnType.cs
- SystemIcmpV6Statistics.cs
- GridViewSortEventArgs.cs
- TrackingParameters.cs
- TreeViewImageIndexConverter.cs
- Byte.cs
- ImageIndexConverter.cs
- Brushes.cs
- SafeMILHandleMemoryPressure.cs
- TreeViewImageKeyConverter.cs
- RawStylusInput.cs
- TargetParameterCountException.cs
- BuildManager.cs
- DataGridViewHitTestInfo.cs
- UriSection.cs
- LiteralControl.cs
- TypeUtils.cs
- FamilyTypeface.cs
- SelectionProcessor.cs
- Authorization.cs
- Sequence.cs
- Itemizer.cs
- TableRowGroup.cs
- SpotLight.cs
- WebPartMovingEventArgs.cs
- TcpAppDomainProtocolHandler.cs
- InputQueue.cs
- CopyEncoder.cs
- ProfileServiceManager.cs
- RandomDelaySendsAsyncResult.cs
- SrgsItemList.cs
- MetadataCacheItem.cs
- MultiPageTextView.cs
- AvTraceFormat.cs
- TypeGeneratedEventArgs.cs
- CompressionTransform.cs
- TextFormatterContext.cs
- GenericIdentity.cs
- File.cs