Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / ServiceModel / SerializableReadOnlyDictionary.cs / 1305376 / SerializableReadOnlyDictionary.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel { using System.Collections; using System.Collections.Generic; [Serializable] class SerializableReadOnlyDictionary: IDictionary { static IDictionary empty; IDictionary dictionary; public SerializableReadOnlyDictionary(IDictionary dictionary) : this(dictionary, true) { } public SerializableReadOnlyDictionary(IDictionary dictionary, bool makeCopy) { if (makeCopy) { this.dictionary = new Dictionary (dictionary); } else { this.dictionary = dictionary; } } public SerializableReadOnlyDictionary(params KeyValuePair [] entries) { this.dictionary = new Dictionary (entries.Length); foreach (KeyValuePair pair in entries) { this.dictionary.Add(pair); } } public static IDictionary Empty { get { if (empty == null) { empty = new SerializableReadOnlyDictionary (new Dictionary (0), false); } return empty; } } public int Count { get { return this.dictionary.Count; } } public bool IsReadOnly { get { return true; } } public ICollection Keys { get { return this.dictionary.Keys; } } public ICollection Values { get { return this.dictionary.Values; } } public V this[K key] { get { return this.dictionary[key]; } set { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } } public void Add(K key, V value) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } public void Add(KeyValuePair item) { 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 Contains(KeyValuePair item) { return this.dictionary.Contains(item); } public bool ContainsKey(K key) { return this.dictionary.ContainsKey(key); } public void CopyTo(KeyValuePair [] array, int arrayIndex) { this.dictionary.CopyTo(array, arrayIndex); } public IEnumerator > GetEnumerator() { return this.dictionary.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } public bool Remove(K key) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } public bool Remove(KeyValuePair item) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); } public bool TryGetValue(K key, out V value) { return this.dictionary.TryGetValue(key, out value); } } } // 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
- SelectionPattern.cs
- GenericAuthenticationEventArgs.cs
- Compiler.cs
- CatalogPartCollection.cs
- IsolationInterop.cs
- ImageKeyConverter.cs
- BridgeDataReader.cs
- AuthenticationConfig.cs
- GridViewRowPresenterBase.cs
- BrowserInteropHelper.cs
- SmiTypedGetterSetter.cs
- AssertFilter.cs
- DocumentGrid.cs
- FusionWrap.cs
- HuffCodec.cs
- SecurityTokenResolver.cs
- DataGridViewColumn.cs
- BitmapScalingModeValidation.cs
- BreakSafeBase.cs
- LayoutDump.cs
- XmlSchemaIdentityConstraint.cs
- HwndSubclass.cs
- FormViewModeEventArgs.cs
- SoapObjectInfo.cs
- HtmlLiteralTextAdapter.cs
- StringOutput.cs
- Span.cs
- ElementsClipboardData.cs
- JsonDeserializer.cs
- LogStore.cs
- Action.cs
- AppDomainUnloadedException.cs
- DataGridViewCheckBoxColumn.cs
- StringUtil.cs
- ToolStripItemEventArgs.cs
- FormViewModeEventArgs.cs
- SingleResultAttribute.cs
- SystemNetworkInterface.cs
- WsdlHelpGeneratorElement.cs
- QueryOpcode.cs
- DecimalSumAggregationOperator.cs
- CodeSnippetExpression.cs
- BuilderInfo.cs
- EntityRecordInfo.cs
- ToolStripSettings.cs
- AlgoModule.cs
- Permission.cs
- AppDomain.cs
- ListViewGroupConverter.cs
- StateBag.cs
- DropDownButton.cs
- CompilerError.cs
- ObjectDataSourceView.cs
- SectionRecord.cs
- Int16KeyFrameCollection.cs
- CodeIndexerExpression.cs
- Image.cs
- DesignSurfaceServiceContainer.cs
- EventTrigger.cs
- CopyOfAction.cs
- RegexCompiler.cs
- ReadOnlyNameValueCollection.cs
- EnumerableRowCollectionExtensions.cs
- UrlMappingsSection.cs
- StrongName.cs
- MSAANativeProvider.cs
- XmlEventCache.cs
- _CookieModule.cs
- HtmlInputFile.cs
- ComponentDispatcherThread.cs
- SinglePageViewer.cs
- ListDependantCardsRequest.cs
- WindowsProgressbar.cs
- SpnegoTokenAuthenticator.cs
- BaseDataBoundControl.cs
- SessionMode.cs
- Point.cs
- SpellerHighlightLayer.cs
- LogStream.cs
- LayoutTable.cs
- XmlLoader.cs
- GeometryDrawing.cs
- Symbol.cs
- FrameworkElement.cs
- IteratorDescriptor.cs
- DropAnimation.xaml.cs
- ClaimComparer.cs
- PlatformNotSupportedException.cs
- TypeConverterValueSerializer.cs
- Scripts.cs
- DoubleConverter.cs
- OrderingInfo.cs
- MarshalDirectiveException.cs
- XsdDateTime.cs
- RtType.cs
- EntityDataSourceViewSchema.cs
- PathGeometry.cs
- DataControlLinkButton.cs
- EastAsianLunisolarCalendar.cs
- SystemKeyConverter.cs