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
- InheritanceAttribute.cs
- DataGridParentRows.cs
- TrustManagerPromptUI.cs
- RawStylusActions.cs
- FixedSOMPage.cs
- SiteIdentityPermission.cs
- HttpHeaderCollection.cs
- WebReference.cs
- SerializerProvider.cs
- WindowsGraphicsCacheManager.cs
- BinaryObjectWriter.cs
- FontStyleConverter.cs
- CacheAxisQuery.cs
- X509SecurityTokenProvider.cs
- HwndAppCommandInputProvider.cs
- PropertyEntry.cs
- IdentifierService.cs
- NotifyCollectionChangedEventArgs.cs
- DebugInfoExpression.cs
- DocumentationServerProtocol.cs
- Helper.cs
- TableLayoutSettings.cs
- XmlDataImplementation.cs
- Repeater.cs
- _NativeSSPI.cs
- CompoundFileDeflateTransform.cs
- Highlights.cs
- Panel.cs
- DesignTimeTemplateParser.cs
- PathGradientBrush.cs
- BoundField.cs
- XLinq.cs
- PageAsyncTaskManager.cs
- BooleanAnimationUsingKeyFrames.cs
- DESCryptoServiceProvider.cs
- TemplateControlCodeDomTreeGenerator.cs
- XmlSchemaNotation.cs
- EventLogPermissionHolder.cs
- VirtualDirectoryMapping.cs
- CompositeFontInfo.cs
- SplitterEvent.cs
- GroupQuery.cs
- GlyphingCache.cs
- Int32Storage.cs
- GenericIdentity.cs
- PeerInvitationResponse.cs
- WindowsFormsSectionHandler.cs
- LoadedOrUnloadedOperation.cs
- WindowsScrollBarBits.cs
- CodeAttributeArgumentCollection.cs
- PaintEvent.cs
- GridViewRow.cs
- ToolboxComponentsCreatingEventArgs.cs
- ResXFileRef.cs
- QueueException.cs
- BindingMAnagerBase.cs
- NonClientArea.cs
- EntityDesignerBuildProvider.cs
- RuntimeWrappedException.cs
- TextControlDesigner.cs
- DependencyPropertyKind.cs
- PrivateFontCollection.cs
- Journaling.cs
- BinHexEncoder.cs
- itemelement.cs
- NegationPusher.cs
- SolidColorBrush.cs
- XDRSchema.cs
- AutomationEventArgs.cs
- PeerHopCountAttribute.cs
- BevelBitmapEffect.cs
- RSAPKCS1SignatureDeformatter.cs
- ObfuscationAttribute.cs
- GacUtil.cs
- XmlTypeMapping.cs
- BooleanFunctions.cs
- SqlProcedureAttribute.cs
- InfoCardTraceRecord.cs
- ReferencedType.cs
- DataListComponentEditor.cs
- SqlDataReader.cs
- WebPartCloseVerb.cs
- HttpCookieCollection.cs
- CodeDomLoader.cs
- _SslSessionsCache.cs
- ProbeDuplexCD1AsyncResult.cs
- TextChange.cs
- WpfKnownMemberInvoker.cs
- ConfigXmlAttribute.cs
- BigInt.cs
- SystemPens.cs
- EntitySetBase.cs
- ScriptControlDescriptor.cs
- HashSet.cs
- DataGrid.cs
- NonBatchDirectoryCompiler.cs
- HideDisabledControlAdapter.cs
- ToolTipService.cs
- UIElement3D.cs
- TextChange.cs