Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Collections / Specialized / StringDictionaryWithComparer.cs / 1305376 / StringDictionaryWithComparer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- // StringDictionary compares keys by converting them to lowercase first, using the Invariant culture. // This is not the right thing to do for file names, registry keys, environment variable etc. // This internal version of StringDictionary accepts an IEqualityComparer and enables you to // customize the string comparison to be StringComparer.OrdinalIgnoreCase for the above cases. namespace System.Collections.Specialized { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.Collections; using System.ComponentModel.Design.Serialization; using System.Globalization; [Serializable] internal class StringDictionaryWithComparer : StringDictionary { public StringDictionaryWithComparer() : this(StringComparer.OrdinalIgnoreCase) { } public StringDictionaryWithComparer(IEqualityComparer comparer) { ReplaceHashtable(new Hashtable(comparer)); } public override string this[string key] { get { if( key == null ) { throw new ArgumentNullException("key"); } return (string) contents[key]; } set { if( key == null ) { throw new ArgumentNullException("key"); } contents[key] = value; } } public override void Add(string key, string value) { if( key == null ) { throw new ArgumentNullException("key"); } contents.Add(key, value); } public override bool ContainsKey(string key) { if( key == null ) { throw new ArgumentNullException("key"); } return contents.ContainsKey(key); } public override void Remove(string key) { if( key == null ) { throw new ArgumentNullException("key"); } contents.Remove(key); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- // StringDictionary compares keys by converting them to lowercase first, using the Invariant culture. // This is not the right thing to do for file names, registry keys, environment variable etc. // This internal version of StringDictionary accepts an IEqualityComparer and enables you to // customize the string comparison to be StringComparer.OrdinalIgnoreCase for the above cases. namespace System.Collections.Specialized { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.Collections; using System.ComponentModel.Design.Serialization; using System.Globalization; [Serializable] internal class StringDictionaryWithComparer : StringDictionary { public StringDictionaryWithComparer() : this(StringComparer.OrdinalIgnoreCase) { } public StringDictionaryWithComparer(IEqualityComparer comparer) { ReplaceHashtable(new Hashtable(comparer)); } public override string this[string key] { get { if( key == null ) { throw new ArgumentNullException("key"); } return (string) contents[key]; } set { if( key == null ) { throw new ArgumentNullException("key"); } contents[key] = value; } } public override void Add(string key, string value) { if( key == null ) { throw new ArgumentNullException("key"); } contents.Add(key, value); } public override bool ContainsKey(string key) { if( key == null ) { throw new ArgumentNullException("key"); } return contents.ContainsKey(key); } public override void Remove(string key) { if( key == null ) { throw new ArgumentNullException("key"); } contents.Remove(key); } } } // 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
- VBCodeProvider.cs
- MessageQueueTransaction.cs
- BoundingRectTracker.cs
- QEncodedStream.cs
- HttpCapabilitiesSectionHandler.cs
- Converter.cs
- DeclarationUpdate.cs
- CachedFontFamily.cs
- Ops.cs
- ScriptModule.cs
- QilFunction.cs
- TimerElapsedEvenArgs.cs
- InternalConfirm.cs
- FixUp.cs
- RSAOAEPKeyExchangeFormatter.cs
- ScaleTransform3D.cs
- ExtendedPropertyCollection.cs
- GridViewPageEventArgs.cs
- OracleNumber.cs
- AttachedPropertyMethodSelector.cs
- safelink.cs
- CodeTypeDeclaration.cs
- FindCriteria.cs
- XPathSelectionIterator.cs
- TransactionFilter.cs
- CategoryGridEntry.cs
- HtmlInputRadioButton.cs
- FillRuleValidation.cs
- WeakRefEnumerator.cs
- Range.cs
- SoapAttributes.cs
- ConfigurationValidatorAttribute.cs
- BitmapMetadataBlob.cs
- ChangeInterceptorAttribute.cs
- SmiMetaData.cs
- Column.cs
- ManualResetEvent.cs
- InvokeProviderWrapper.cs
- SchemaNames.cs
- HttpProcessUtility.cs
- TransformConverter.cs
- CommentAction.cs
- SimpleBitVector32.cs
- EnumValAlphaComparer.cs
- EncoderExceptionFallback.cs
- ProfileGroupSettings.cs
- CheckBox.cs
- TemplatePartAttribute.cs
- SyndicationContent.cs
- UnknownWrapper.cs
- SortedSet.cs
- ValueOfAction.cs
- ToolStripDesigner.cs
- AttributeQuery.cs
- StylusButton.cs
- COM2ComponentEditor.cs
- DBParameter.cs
- ProcessThread.cs
- ComplexType.cs
- Pair.cs
- AsyncPostBackErrorEventArgs.cs
- DescriptionAttribute.cs
- LinearGradientBrush.cs
- StyleModeStack.cs
- _Connection.cs
- DrawingBrush.cs
- ReverseInheritProperty.cs
- DesignerTextViewAdapter.cs
- ExtenderControl.cs
- WasHostedComPlusFactory.cs
- ConnectionManagementElement.cs
- HttpServerChannel.cs
- ImageDrawing.cs
- TraceData.cs
- ExpressionEditorAttribute.cs
- NonBatchDirectoryCompiler.cs
- FixedHighlight.cs
- FileSecurity.cs
- AppDomainUnloadedException.cs
- ListView.cs
- CredentialSelector.cs
- ReliabilityContractAttribute.cs
- namescope.cs
- TypedRowHandler.cs
- Roles.cs
- GridViewRowCollection.cs
- KeyEventArgs.cs
- TracePayload.cs
- MapPathBasedVirtualPathProvider.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- parserscommon.cs
- Rotation3DAnimation.cs
- CategoryAttribute.cs
- FileIOPermission.cs
- OleDbConnectionFactory.cs
- System.Data_BID.cs
- WindowsContainer.cs
- VectorKeyFrameCollection.cs
- DateTimeOffsetConverter.cs
- WmlTextBoxAdapter.cs