Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Speech / Src / Internal / ReadOnlyDictionary.cs / 1 / ReadOnlyDictionary.cs
//------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; namespace System.Speech.Internal { internal class ReadOnlyDictionary: IDictionary { public int Count { get { return _dictionary.Count; } } public IEnumerator > GetEnumerator () { return _dictionary.GetEnumerator (); } public V this [K key] { get { return _dictionary [key]; } set { throw new NotSupportedException (SR.Get (SRID.CollectionReadOnly)); } } // Other methods are a pass through to the underlying collection: public bool IsReadOnly { get { return true; } } public bool Contains (KeyValuePair key) { return _dictionary.ContainsKey (key.Key); } public bool ContainsKey (K key) { return _dictionary.ContainsKey (key); } public void CopyTo (KeyValuePair [] array, int index) { ((ICollection >) _dictionary).CopyTo (array, index); } public ICollection Keys { // According to the source of IDictionary.Keys this is a read-only collection. get { return _dictionary.Keys; } } public ICollection Values { // According to the source of IDictionary.Keys this is a read-write collection, // but is a copy of the main dictionary so there's no way to change anything in the main collection. get { return _dictionary.Values; } } // Read-only collection so throw on these methods: public void Add (KeyValuePair key) { throw new NotSupportedException (SR.Get (SRID.CollectionReadOnly)); } public void Add (K key, V value) { throw new NotSupportedException (SR.Get (SRID.CollectionReadOnly)); } public void Clear () { throw new NotSupportedException (SR.Get (SRID.CollectionReadOnly)); } public bool Remove (KeyValuePair key) { throw new NotSupportedException (SR.Get (SRID.CollectionReadOnly)); } public bool Remove (K key) { throw new NotSupportedException (SR.Get (SRID.CollectionReadOnly)); } IEnumerator IEnumerable.GetEnumerator () { return ((IEnumerable >) this).GetEnumerator (); } bool IDictionary .TryGetValue (K key, out V value) { return InternalDictionary.TryGetValue (key, out value); } // Allow internal code to manipulate internal collection internal Dictionary InternalDictionary { get { return _dictionary; } //set { _dictionary = value; } } private Dictionary _dictionary = new Dictionary (); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DesignerTextWriter.cs
- ScopedKnownTypes.cs
- ResourceDefaultValueAttribute.cs
- ColumnPropertiesGroup.cs
- MethodExpr.cs
- BulletedListDesigner.cs
- DbParameterCollection.cs
- TaskDesigner.cs
- SoapIncludeAttribute.cs
- ImageConverter.cs
- SurrogateSelector.cs
- MatrixConverter.cs
- AssemblySettingAttributes.cs
- Hyperlink.cs
- LabelLiteral.cs
- ObjectViewFactory.cs
- CustomExpressionEventArgs.cs
- OleAutBinder.cs
- FontDialog.cs
- ErrorTolerantObjectWriter.cs
- Hex.cs
- DbDataReader.cs
- TableLayout.cs
- ScaleTransform.cs
- ContextStack.cs
- MetadataSet.cs
- ExpressionEditorAttribute.cs
- Preprocessor.cs
- CommonDialog.cs
- TableItemStyle.cs
- TransformerInfoCollection.cs
- InteropBitmapSource.cs
- ErrorWrapper.cs
- ExpressionVisitor.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- X509ImageLogo.cs
- WarningException.cs
- Serializer.cs
- ChannelSinkStacks.cs
- ToolTipService.cs
- PublisherMembershipCondition.cs
- AssociatedControlConverter.cs
- SiteMapDataSourceView.cs
- TableCellAutomationPeer.cs
- LambdaExpression.cs
- VisualTreeUtils.cs
- EndpointConfigContainer.cs
- EnglishPluralizationService.cs
- MenuCommands.cs
- _OSSOCK.cs
- WmpBitmapEncoder.cs
- DbFunctionCommandTree.cs
- ProofTokenCryptoHandle.cs
- HtmlElementErrorEventArgs.cs
- KeyBinding.cs
- SessionEndedEventArgs.cs
- ClientBuildManager.cs
- CompositeActivityTypeDescriptorProvider.cs
- webbrowsersite.cs
- XmlTextWriter.cs
- DataGridViewCellMouseEventArgs.cs
- SerialReceived.cs
- DataGridViewCellEventArgs.cs
- SchemaImporterExtension.cs
- _ConnectStream.cs
- CqlParserHelpers.cs
- TableColumn.cs
- AppDomainUnloadedException.cs
- SoapUnknownHeader.cs
- RootProfilePropertySettingsCollection.cs
- WebCategoryAttribute.cs
- ValueQuery.cs
- XmlSchemaFacet.cs
- TextCompositionManager.cs
- HyperLink.cs
- OutputCacheProfileCollection.cs
- FormViewUpdateEventArgs.cs
- EntityDataSourceReferenceGroup.cs
- RequestTimeoutManager.cs
- BitmapMetadataEnumerator.cs
- FormsAuthenticationModule.cs
- ConfigurationManagerHelperFactory.cs
- EventPropertyMap.cs
- SQLBinary.cs
- TrailingSpaceComparer.cs
- ConditionalWeakTable.cs
- DefaultPropertyAttribute.cs
- ActiveXMessageFormatter.cs
- AssemblyLoader.cs
- RoutingTable.cs
- ThreadInterruptedException.cs
- ObjectKeyFrameCollection.cs
- PrintPreviewDialog.cs
- CollectionBase.cs
- FileCodeGroup.cs
- EdmFunctionAttribute.cs
- LineServicesCallbacks.cs
- WhitespaceRule.cs
- BamlMapTable.cs
- ApplicationHost.cs