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
- ComponentManagerBroker.cs
- FullTextState.cs
- ErrorProvider.cs
- Deflater.cs
- BindingSource.cs
- SqlParameterizer.cs
- PriorityChain.cs
- XmlElementElement.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- TailCallAnalyzer.cs
- RequestCachePolicy.cs
- DiagnosticsConfigurationHandler.cs
- FormatControl.cs
- ConstructorBuilder.cs
- MediaElementAutomationPeer.cs
- IdentityManager.cs
- FormsIdentity.cs
- XsdDataContractImporter.cs
- NumericExpr.cs
- PropertyValueEditor.cs
- ScrollItemPattern.cs
- counter.cs
- WorkingDirectoryEditor.cs
- FileDialog_Vista_Interop.cs
- XamlTemplateSerializer.cs
- indexingfiltermarshaler.cs
- PrintDialog.cs
- Proxy.cs
- SafeFileMapViewHandle.cs
- CqlLexer.cs
- RecordsAffectedEventArgs.cs
- UriExt.cs
- ArgIterator.cs
- CmsInterop.cs
- BuildProviderAppliesToAttribute.cs
- FontFamilyIdentifier.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- EventBuilder.cs
- WebPartCancelEventArgs.cs
- HttpListenerPrefixCollection.cs
- UniqueConstraint.cs
- SyntaxCheck.cs
- MultilineStringConverter.cs
- ImageCodecInfo.cs
- SiteMapNodeItem.cs
- ReflectEventDescriptor.cs
- OdbcPermission.cs
- UnaryNode.cs
- ModelUIElement3D.cs
- ISAPIRuntime.cs
- DbQueryCommandTree.cs
- UnsafeNativeMethods.cs
- TransformerInfoCollection.cs
- Typography.cs
- SafeEventLogWriteHandle.cs
- WebPartTransformer.cs
- UriParserTemplates.cs
- HttpClientChannel.cs
- XmlIgnoreAttribute.cs
- ExtensibleClassFactory.cs
- OleDbEnumerator.cs
- BuildProvider.cs
- RunInstallerAttribute.cs
- DrawingContextWalker.cs
- OracleTransaction.cs
- CssTextWriter.cs
- UnauthorizedWebPart.cs
- XmlBindingWorker.cs
- ReliableMessagingVersionConverter.cs
- GlobalizationSection.cs
- AsyncOperationManager.cs
- invalidudtexception.cs
- ProcessInputEventArgs.cs
- BuildProvidersCompiler.cs
- BindableTemplateBuilder.cs
- NoneExcludedImageIndexConverter.cs
- TypedTableBase.cs
- WebRequestModuleElement.cs
- ThreadPool.cs
- TextEncodedRawTextWriter.cs
- TdsParserStaticMethods.cs
- DataProtectionSecurityStateEncoder.cs
- XamlStyleSerializer.cs
- SingleQueryOperator.cs
- AstNode.cs
- SqlBulkCopyColumnMappingCollection.cs
- DataGridViewImageCell.cs
- ObjectListItem.cs
- BooleanAnimationUsingKeyFrames.cs
- DatePicker.cs
- XPathNodePointer.cs
- BamlBinaryWriter.cs
- DataGridView.cs
- LogStream.cs
- AbstractExpressions.cs
- SelectedGridItemChangedEvent.cs
- DataGridViewColumnStateChangedEventArgs.cs
- XmlFormatWriterGenerator.cs
- BuildDependencySet.cs
- GetBrowserTokenRequest.cs