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
- StringFunctions.cs
- XmlDeclaration.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- XmlSchemaAttributeGroupRef.cs
- HtmlInputCheckBox.cs
- UnicodeEncoding.cs
- WorkflowOperationBehavior.cs
- QueueAccessMode.cs
- ZoomPercentageConverter.cs
- RSACryptoServiceProvider.cs
- cookie.cs
- SystemColors.cs
- ConcurrentDictionary.cs
- CacheForPrimitiveTypes.cs
- DataGridViewCheckBoxColumn.cs
- InstanceNormalEvent.cs
- GridItemPatternIdentifiers.cs
- ScriptingProfileServiceSection.cs
- ModifierKeysValueSerializer.cs
- WebPartManagerInternals.cs
- ImageKeyConverter.cs
- PartitionResolver.cs
- URL.cs
- PointIndependentAnimationStorage.cs
- BitmapImage.cs
- SizeConverter.cs
- EtwTrace.cs
- latinshape.cs
- SharedStatics.cs
- BuilderInfo.cs
- WebPartEditorOkVerb.cs
- mediaeventargs.cs
- XmlIterators.cs
- DataGridViewColumnEventArgs.cs
- Base64Stream.cs
- LambdaCompiler.cs
- SqlDataSourceFilteringEventArgs.cs
- ToolStripRenderer.cs
- PolyBezierSegment.cs
- SchemaElementLookUpTable.cs
- HitTestParameters3D.cs
- SpeechDetectedEventArgs.cs
- ObjectTag.cs
- XmlTypeAttribute.cs
- wpf-etw.cs
- TextEditorLists.cs
- DataGridLength.cs
- GridViewSelectEventArgs.cs
- UserNameSecurityTokenAuthenticator.cs
- HtmlElementCollection.cs
- RectangleF.cs
- ConnectorMovedEventArgs.cs
- RequiredFieldValidator.cs
- PropertyConverter.cs
- ButtonField.cs
- AnnotationHelper.cs
- HtmlInputFile.cs
- QuaternionIndependentAnimationStorage.cs
- ListControlConvertEventArgs.cs
- ZipIOLocalFileHeader.cs
- Clock.cs
- figurelengthconverter.cs
- ByteStreamGeometryContext.cs
- XmlCountingReader.cs
- ScriptMethodAttribute.cs
- StringComparer.cs
- CompositeDataBoundControl.cs
- WebCategoryAttribute.cs
- SQLByte.cs
- IisTraceWebEventProvider.cs
- CodeMemberProperty.cs
- Operand.cs
- IPGlobalProperties.cs
- AuthenticationModuleElement.cs
- OciHandle.cs
- FileLogRecord.cs
- AutomationPatternInfo.cs
- BitVector32.cs
- DiagnosticsConfiguration.cs
- ChildChangedEventArgs.cs
- StyleSheetRefUrlEditor.cs
- DBCommand.cs
- ValueSerializerAttribute.cs
- FeatureSupport.cs
- SafeReversePInvokeHandle.cs
- RenderTargetBitmap.cs
- WinEventTracker.cs
- ListParaClient.cs
- MemoryMappedFile.cs
- FileDialog.cs
- SubqueryRules.cs
- GorillaCodec.cs
- ComponentEditorPage.cs
- RepeaterItem.cs
- WinCategoryAttribute.cs
- NetworkStream.cs
- HttpModuleAction.cs
- baseaxisquery.cs
- DockPanel.cs
- XPathException.cs