Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ReadOnlyDictionary.cs / 1 / ReadOnlyDictionary.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; internal sealed class ReadOnlyDictionary: IDictionary { IDictionary dictionary; bool isFixedSize; internal ReadOnlyDictionary(IDictionary dictionary) : this(dictionary, true) { // empty } internal ReadOnlyDictionary(IDictionary dictionary, bool makeCopy) { if (makeCopy) this.dictionary = new Dictionary (dictionary); else this.dictionary = dictionary; this.isFixedSize = makeCopy; } public V this[K key] { get { return this.dictionary[key]; } set { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } } public ICollection Keys { get { return this.dictionary.Keys; } } public ICollection Values { get { return this.dictionary.Values; } } public int Count { get { return this.dictionary.Count; } } public bool ContainsKey(K key) { return this.dictionary.ContainsKey(key); } public void Add(K key, V value) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } public void Clear() { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } public bool IsReadOnly { get { return true; } } public bool IsFixedSize { get { return this.isFixedSize; } } public bool TryGetValue(K key, out V value) { return this.dictionary.TryGetValue(key, out value); } void ICollection >.Add(KeyValuePair keyValuePair) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } bool ICollection >.Contains(KeyValuePair keyValuePair) { return (this.ContainsKey(keyValuePair.Key) && this[keyValuePair.Key].Equals(keyValuePair.Value)); } bool ICollection >.Remove(KeyValuePair keyValuePair) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } public bool Remove(K key) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } void ICollection >.CopyTo(KeyValuePair [] array, int arrayIndex) { ((IDictionary )this.dictionary).CopyTo(array, arrayIndex); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable >)this).GetEnumerator(); } IEnumerator > IEnumerable >.GetEnumerator() { return ((IDictionary )this.dictionary).GetEnumerator(); } } } // 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
- CachedBitmap.cs
- SqlCacheDependency.cs
- InvalidCastException.cs
- ComPlusInstanceContextInitializer.cs
- CoTaskMemHandle.cs
- IssuedTokenClientElement.cs
- WsdlBuildProvider.cs
- XmlEnumAttribute.cs
- FlowDocumentPageViewerAutomationPeer.cs
- ColumnWidthChangingEvent.cs
- LowerCaseStringConverter.cs
- AlphaSortedEnumConverter.cs
- ContextQuery.cs
- ItemChangedEventArgs.cs
- ListViewCommandEventArgs.cs
- DataControlFieldCollection.cs
- MetafileHeaderEmf.cs
- StylusPointProperty.cs
- DbTransaction.cs
- SqlComparer.cs
- SaveFileDialog.cs
- AutoGeneratedField.cs
- FontResourceCache.cs
- ResourceDescriptionAttribute.cs
- TemplateParser.cs
- DataGridViewCellCollection.cs
- ApplyTemplatesAction.cs
- CodeExpressionStatement.cs
- AttachmentCollection.cs
- DocumentViewerAutomationPeer.cs
- QilDataSource.cs
- KeyedHashAlgorithm.cs
- BlockCollection.cs
- JoinCqlBlock.cs
- OrthographicCamera.cs
- Row.cs
- NamespaceQuery.cs
- FormsIdentity.cs
- KeySplineConverter.cs
- AdapterDictionary.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- HtmlSelect.cs
- PeerEndPoint.cs
- HitTestParameters3D.cs
- FormViewUpdateEventArgs.cs
- SmiMetaData.cs
- XmlSchemaImporter.cs
- CodeArrayIndexerExpression.cs
- Region.cs
- RightNameExpirationInfoPair.cs
- ACE.cs
- ProgressBar.cs
- HttpContext.cs
- ToolStripSplitButton.cs
- ConfigurationManagerHelperFactory.cs
- Section.cs
- ListBoxAutomationPeer.cs
- SqlBooleanizer.cs
- ProgressPage.cs
- NegotiateStream.cs
- SimpleType.cs
- PropertiesTab.cs
- ColorBlend.cs
- ByteArrayHelperWithString.cs
- SmtpLoginAuthenticationModule.cs
- ValidationErrorEventArgs.cs
- MenuTracker.cs
- UnsafeNativeMethods.cs
- KoreanCalendar.cs
- AddInAdapter.cs
- PeerCustomResolverElement.cs
- RefType.cs
- FileVersionInfo.cs
- RealProxy.cs
- FormViewInsertEventArgs.cs
- Encoder.cs
- QilInvoke.cs
- PropertySegmentSerializer.cs
- ColumnResult.cs
- SynchronizationLockException.cs
- TemplatePropertyEntry.cs
- SyndicationSerializer.cs
- RecognizeCompletedEventArgs.cs
- ToolboxItemWrapper.cs
- ObjectDataSourceFilteringEventArgs.cs
- QueryAccessibilityHelpEvent.cs
- CacheMemory.cs
- _LocalDataStoreMgr.cs
- DataGridLinkButton.cs
- HandlerWithFactory.cs
- Padding.cs
- cryptoapiTransform.cs
- ProgressBarRenderer.cs
- RepeaterCommandEventArgs.cs
- DataAdapter.cs
- ListViewContainer.cs
- XmlIlVisitor.cs
- PeerCollaboration.cs
- StyleBamlRecordReader.cs
- CodeCatchClauseCollection.cs