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
- CacheVirtualItemsEvent.cs
- CatalogPartCollection.cs
- VisemeEventArgs.cs
- BufferedMessageData.cs
- SessionPageStateSection.cs
- LateBoundBitmapDecoder.cs
- KnownAssembliesSet.cs
- Metadata.cs
- AssociationEndMember.cs
- Delay.cs
- Propagator.cs
- XmlSerializer.cs
- PartialTrustHelpers.cs
- TextBox.cs
- TableLayoutPanelResizeGlyph.cs
- LinkedResourceCollection.cs
- QilBinary.cs
- WaitHandleCannotBeOpenedException.cs
- ComplexPropertyEntry.cs
- TextTreeText.cs
- StickyNoteAnnotations.cs
- GridViewRowPresenter.cs
- Internal.cs
- FrugalList.cs
- SerialPinChanges.cs
- HostingPreferredMapPath.cs
- MemberAssignmentAnalysis.cs
- CommandConverter.cs
- PropagatorResult.cs
- TemplateControlParser.cs
- RequestTimeoutManager.cs
- CaseExpr.cs
- ImageAttributes.cs
- WorkflowOperationBehavior.cs
- JapaneseLunisolarCalendar.cs
- StorageMappingItemLoader.cs
- ReadOnlyHierarchicalDataSourceView.cs
- NonParentingControl.cs
- controlskin.cs
- TrustManagerMoreInformation.cs
- ServiceNotStartedException.cs
- EmptyStringExpandableObjectConverter.cs
- PieceNameHelper.cs
- FontFamily.cs
- DataSourceExpressionCollection.cs
- VirtualPathUtility.cs
- TextSimpleMarkerProperties.cs
- GlyphRun.cs
- Divide.cs
- XmlILAnnotation.cs
- ClientFormsAuthenticationMembershipProvider.cs
- NumericPagerField.cs
- Wildcard.cs
- PrintingPermissionAttribute.cs
- DesignerView.Commands.cs
- MenuStrip.cs
- InkSerializer.cs
- ListItemCollection.cs
- ExceptionUtility.cs
- FileEnumerator.cs
- SymLanguageVendor.cs
- ListViewItem.cs
- DataRowIndexBuffer.cs
- ToolBarOverflowPanel.cs
- ElementUtil.cs
- BCLDebug.cs
- TextParagraphCache.cs
- DataContract.cs
- HttpHandlersSection.cs
- ModelUIElement3D.cs
- ProcessManager.cs
- XmlTextWriter.cs
- StrongNameUtility.cs
- BindToObject.cs
- PopupControlService.cs
- _NetworkingPerfCounters.cs
- SchemaElement.cs
- BaseParser.cs
- MissingFieldException.cs
- WorkItem.cs
- TextParagraphView.cs
- XamlToRtfParser.cs
- DispatcherProcessingDisabled.cs
- XsltInput.cs
- PropertyEmitter.cs
- CustomLineCap.cs
- ScriptManager.cs
- ContainerParaClient.cs
- FontFamily.cs
- XmlSchemaSimpleTypeRestriction.cs
- Policy.cs
- Repeater.cs
- DesignerActionMethodItem.cs
- SharedRuntimeState.cs
- Expr.cs
- SqlProviderServices.cs
- ExpandSegment.cs
- PictureBox.cs
- WindowClosedEventArgs.cs
- DbExpressionVisitor.cs