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
- WeakHashtable.cs
- Membership.cs
- RectKeyFrameCollection.cs
- BinHexEncoding.cs
- HtmlHead.cs
- XPathBinder.cs
- DbFunctionCommandTree.cs
- LinkLabelLinkClickedEvent.cs
- CryptoProvider.cs
- RemoteWebConfigurationHostStream.cs
- CommandEventArgs.cs
- PluggableProtocol.cs
- StrokeNodeOperations.cs
- Version.cs
- WebPartHelpVerb.cs
- DateTimeParse.cs
- DataServiceResponse.cs
- PackageDocument.cs
- WorkflowTimerService.cs
- OperationExecutionFault.cs
- ObjectMaterializedEventArgs.cs
- Dispatcher.cs
- DebugView.cs
- SerializationObjectManager.cs
- WsrmFault.cs
- HttpAsyncResult.cs
- ActiveDocumentEvent.cs
- HttpCookie.cs
- FaultFormatter.cs
- cookiecollection.cs
- SignatureHelper.cs
- ProtocolViolationException.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- ToolStripPanel.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- WinEventTracker.cs
- ParameterBuilder.cs
- DeflateStreamAsyncResult.cs
- MaskedTextBoxTextEditor.cs
- DataGridDetailsPresenter.cs
- EntityEntry.cs
- Debug.cs
- HtmlInputFile.cs
- QilSortKey.cs
- HiddenField.cs
- RawStylusInputCustomDataList.cs
- EntryWrittenEventArgs.cs
- SpeechSynthesizer.cs
- XmlObjectSerializerWriteContextComplex.cs
- SettingsPropertyIsReadOnlyException.cs
- AsyncWaitHandle.cs
- AsyncStreamReader.cs
- CopyAttributesAction.cs
- TypefaceCollection.cs
- LifetimeServices.cs
- WriteFileContext.cs
- EventHandlersDesigner.cs
- DrawingServices.cs
- Rethrow.cs
- JpegBitmapDecoder.cs
- NumberFormatInfo.cs
- KeyTimeConverter.cs
- SqlTransaction.cs
- Comparer.cs
- QilGeneratorEnv.cs
- XmlDataSourceNodeDescriptor.cs
- IdentityNotMappedException.cs
- TableRowGroup.cs
- WaitHandle.cs
- MeshGeometry3D.cs
- WebPartZone.cs
- OdbcStatementHandle.cs
- WindowsBrush.cs
- RenderingBiasValidation.cs
- RegexWriter.cs
- recordstatescratchpad.cs
- DelegatingMessage.cs
- DbProviderFactory.cs
- SoapObjectInfo.cs
- Transform3DCollection.cs
- AnnouncementInnerClient11.cs
- UnsafeNativeMethods.cs
- DynamicHyperLink.cs
- BaseCAMarshaler.cs
- SessionIDManager.cs
- Block.cs
- WpfXamlType.cs
- DesigntimeLicenseContextSerializer.cs
- TextViewBase.cs
- SessionIDManager.cs
- DataSourceConverter.cs
- ReflectTypeDescriptionProvider.cs
- EntitySqlException.cs
- ProfessionalColors.cs
- QilTernary.cs
- TextEditorContextMenu.cs
- CompositeControlDesigner.cs
- _ScatterGatherBuffers.cs
- AssociatedControlConverter.cs
- CharAnimationBase.cs