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
- OleDbParameterCollection.cs
- BitVector32.cs
- FormViewUpdatedEventArgs.cs
- TransferRequestHandler.cs
- ItemChangedEventArgs.cs
- LinkLabel.cs
- RadioButton.cs
- PageTextBox.cs
- ResourcesBuildProvider.cs
- DetailsViewUpdateEventArgs.cs
- CheckBox.cs
- ListViewSelectEventArgs.cs
- MeasureItemEvent.cs
- DictionaryTraceRecord.cs
- EmptyWithCancelationCheckWorkItem.cs
- TextRunProperties.cs
- MethodRental.cs
- BoundingRectTracker.cs
- Size3D.cs
- Utils.cs
- SmtpDigestAuthenticationModule.cs
- DropShadowBitmapEffect.cs
- EndpointAddressAugust2004.cs
- CustomAssemblyResolver.cs
- ServiceAuthorizationBehavior.cs
- MaskInputRejectedEventArgs.cs
- CellNormalizer.cs
- PropertyGrid.cs
- EdmToObjectNamespaceMap.cs
- DataRow.cs
- HtmlContainerControl.cs
- PersonalizationStateQuery.cs
- DictionaryKeyPropertyAttribute.cs
- BackgroundWorker.cs
- LayoutTable.cs
- X509IssuerSerialKeyIdentifierClause.cs
- DocumentViewerAutomationPeer.cs
- TextSchema.cs
- OutputCacheProviderCollection.cs
- DurableInstancingOptions.cs
- ReferenceSchema.cs
- ResolveCompletedEventArgs.cs
- BindValidationContext.cs
- RowsCopiedEventArgs.cs
- CallbackHandler.cs
- InsufficientMemoryException.cs
- QueryResponse.cs
- CultureSpecificStringDictionary.cs
- XmlSerializerNamespaces.cs
- Cursor.cs
- localization.cs
- AttributeXamlType.cs
- CoTaskMemHandle.cs
- ControlIdConverter.cs
- PartialCachingAttribute.cs
- TypeGenericEnumerableViewSchema.cs
- HideDisabledControlAdapter.cs
- ObjectManager.cs
- NoneExcludedImageIndexConverter.cs
- LinqDataSourceView.cs
- CommandLibraryHelper.cs
- CompoundFileStreamReference.cs
- InstanceStore.cs
- StylusSystemGestureEventArgs.cs
- WinInet.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- ListBindingHelper.cs
- ServiceProviders.cs
- DebuggerService.cs
- ClientTargetCollection.cs
- ServerType.cs
- DataGridRow.cs
- BinaryWriter.cs
- CodeFieldReferenceExpression.cs
- SqlProcedureAttribute.cs
- FrameworkContentElement.cs
- HandledMouseEvent.cs
- RuntimeResourceSet.cs
- LayoutExceptionEventArgs.cs
- DbBuffer.cs
- AppliedDeviceFiltersEditor.cs
- MessageDecoder.cs
- _ListenerAsyncResult.cs
- XmlSchemaExternal.cs
- ClientSponsor.cs
- DesignSurfaceServiceContainer.cs
- ConstraintConverter.cs
- DiscardableAttribute.cs
- TableLayoutSettingsTypeConverter.cs
- InstancePersistenceContext.cs
- PngBitmapDecoder.cs
- ContainerParaClient.cs
- AddInSegmentDirectoryNotFoundException.cs
- WebHttpDispatchOperationSelector.cs
- ByteKeyFrameCollection.cs
- DataBindingExpressionBuilder.cs
- CreateUserWizard.cs
- DirectoryObjectSecurity.cs
- NonParentingControl.cs
- DictionaryTraceRecord.cs