Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Collections / EmptyReadOnlyDictionaryInternal.cs / 1 / EmptyReadOnlyDictionaryInternal.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: ListDictionaryInternal ** ** ** Purpose: List for exceptions. ** ** ===========================================================*/ namespace System.Collections { /// This is a simple implementation of IDictionary that is empty and readonly. [Serializable] internal sealed class EmptyReadOnlyDictionaryInternal: IDictionary { // Note that this class must be agile with respect to AppDomains. See its usage in // System.Exception to understand why this is the case. public EmptyReadOnlyDictionaryInternal() { } // IEnumerable members IEnumerator IEnumerable.GetEnumerator() { return new NodeEnumerator(); } // ICollection members public void CopyTo(Array array, int index) { if (array==null) throw new ArgumentNullException("array"); if (array.Rank != 1) throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); if (index < 0) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if ( array.Length - index < this.Count ) throw new ArgumentException( Environment.GetResourceString("ArgumentOutOfRange_Index"), "index"); // the actual copy is a NOP } public int Count { get { return 0; } } public Object SyncRoot { get { return this; } } public bool IsSynchronized { get { return false; } } // IDictionary members public Object this[Object key] { get { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } return null; } set { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } if (!key.GetType().IsSerializable) throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "key"); if( (value != null) && (!value.GetType().IsSerializable ) ) throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "value"); throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); } } public ICollection Keys { get { return new Object[0]; } } public ICollection Values { get { return new Object[0]; } } public bool Contains(Object key) { return false; } public void Add(Object key, Object value) { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } if (!key.GetType().IsSerializable) throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "key" ); if( (value != null) && (!value.GetType().IsSerializable) ) throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "value"); throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); } public void Clear() { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); } public bool IsReadOnly { get { return true; } } public bool IsFixedSize { get { return true; } } public IDictionaryEnumerator GetEnumerator() { return new NodeEnumerator(); } public void Remove(Object key) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); } private sealed class NodeEnumerator : IDictionaryEnumerator { public NodeEnumerator() { } // IEnumerator members public bool MoveNext() { return false; } public Object Current { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } } public void Reset() { } // IDictionaryEnumerator members public Object Key { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } } public Object Value { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } } public DictionaryEntry Entry { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BasicExpressionVisitor.cs
- LeftCellWrapper.cs
- XmlArrayItemAttributes.cs
- EncodingDataItem.cs
- MsmqIntegrationSecurityMode.cs
- TypeInitializationException.cs
- SettingsProperty.cs
- EastAsianLunisolarCalendar.cs
- SystemTcpConnection.cs
- InputBindingCollection.cs
- OperationResponse.cs
- UrlPropertyAttribute.cs
- SqlProviderServices.cs
- ContextQuery.cs
- WindowsGraphicsCacheManager.cs
- Icon.cs
- COM2ColorConverter.cs
- EntityProviderServices.cs
- StringUtil.cs
- SqlCacheDependency.cs
- IdnElement.cs
- entityreference_tresulttype.cs
- TimeSpanStorage.cs
- DataSourceControlBuilder.cs
- ConfigXmlComment.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- QueryOutputWriter.cs
- WriteTimeStream.cs
- PartialCachingAttribute.cs
- FileRegion.cs
- ISCIIEncoding.cs
- ProviderBase.cs
- OracleDataAdapter.cs
- UseAttributeSetsAction.cs
- ParallelTimeline.cs
- BindToObject.cs
- ExpressionBindingCollection.cs
- GroupBoxAutomationPeer.cs
- OleStrCAMarshaler.cs
- SeverityFilter.cs
- FrameworkReadOnlyPropertyMetadata.cs
- Package.cs
- ExpressionEvaluator.cs
- ConfigurationStrings.cs
- Types.cs
- FloatUtil.cs
- Point.cs
- XmlCompatibilityReader.cs
- StorageEntityContainerMapping.cs
- SqlConnectionHelper.cs
- _OSSOCK.cs
- TaskResultSetter.cs
- EntityRecordInfo.cs
- RealProxy.cs
- FocusManager.cs
- TemplatePropertyEntry.cs
- TextServicesDisplayAttribute.cs
- _AutoWebProxyScriptEngine.cs
- ComponentManagerBroker.cs
- Empty.cs
- _ChunkParse.cs
- CodeIndexerExpression.cs
- PropertyGeneratedEventArgs.cs
- ClientOptions.cs
- MouseBinding.cs
- QuerySubExprEliminator.cs
- HorizontalAlignConverter.cs
- MultiBindingExpression.cs
- AssertFilter.cs
- RowVisual.cs
- DateTimeStorage.cs
- TextEffect.cs
- MediaContextNotificationWindow.cs
- NavigationExpr.cs
- HttpApplicationFactory.cs
- TextTreeUndo.cs
- securestring.cs
- MetafileHeaderWmf.cs
- ColumnReorderedEventArgs.cs
- safex509handles.cs
- MemberPathMap.cs
- ServiceContractViewControl.cs
- MultiSelector.cs
- IncrementalReadDecoders.cs
- CqlGenerator.cs
- HtmlEmptyTagControlBuilder.cs
- WindowsScrollBarBits.cs
- DispatcherHooks.cs
- DataGridViewColumnStateChangedEventArgs.cs
- Quaternion.cs
- Application.cs
- CaseCqlBlock.cs
- VariableDesigner.xaml.cs
- AppSecurityManager.cs
- WorkflowOwnershipException.cs
- XmlSchemaComplexContentRestriction.cs
- Zone.cs
- ObjectConverter.cs
- DrawingContextDrawingContextWalker.cs
- LoginDesigner.cs