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
- CanonicalXml.cs
- SynchronizationValidator.cs
- SafeSystemMetrics.cs
- WeakHashtable.cs
- GeneralEndpointIdentity.cs
- StringPropertyBuilder.cs
- HighlightComponent.cs
- XmlnsCompatibleWithAttribute.cs
- SafeSystemMetrics.cs
- BoundColumn.cs
- ManagementQuery.cs
- XmlUtf8RawTextWriter.cs
- PropertyValidationContext.cs
- Ray3DHitTestResult.cs
- TripleDESCryptoServiceProvider.cs
- UIHelper.cs
- DateTimePicker.cs
- RepeaterDesigner.cs
- AutomationPatternInfo.cs
- TableLayoutRowStyleCollection.cs
- WsdlBuildProvider.cs
- ExplicitDiscriminatorMap.cs
- WindowsTab.cs
- SortExpressionBuilder.cs
- Application.cs
- OwnerDrawPropertyBag.cs
- ControlParameter.cs
- MenuAutoFormat.cs
- PerformanceCounterPermissionAttribute.cs
- WindowsFormsSynchronizationContext.cs
- ResourceDictionaryCollection.cs
- DataColumnMapping.cs
- KoreanCalendar.cs
- ReferencedAssembly.cs
- DataGridPagingPage.cs
- Utils.cs
- ReadOnlyDataSource.cs
- CustomCategoryAttribute.cs
- BaseParagraph.cs
- Journal.cs
- MetafileHeader.cs
- NamespaceDecl.cs
- Documentation.cs
- IconConverter.cs
- CuspData.cs
- KeyFrames.cs
- DispatcherHookEventArgs.cs
- DataAdapter.cs
- RsaSecurityToken.cs
- ZipFileInfo.cs
- StoragePropertyMapping.cs
- SecureConversationVersion.cs
- BinaryCommonClasses.cs
- __ComObject.cs
- srgsitem.cs
- LineVisual.cs
- ServiceDescriptionImporter.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- DataGridColumnReorderingEventArgs.cs
- EventQueueState.cs
- VectorAnimationUsingKeyFrames.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- StylusPlugin.cs
- DataGridLengthConverter.cs
- SchemaCollectionCompiler.cs
- XmlSchemaFacet.cs
- X509RawDataKeyIdentifierClause.cs
- AssemblyUtil.cs
- MetadataArtifactLoaderCompositeFile.cs
- WinHttpWebProxyFinder.cs
- DbProviderFactories.cs
- StandardCommands.cs
- DesignBinding.cs
- SecurityUtils.cs
- ExpressionBuilderContext.cs
- DataGridCellsPanel.cs
- SetterTriggerConditionValueConverter.cs
- MatrixUtil.cs
- PathSegmentCollection.cs
- DataBoundLiteralControl.cs
- XmlElementAttributes.cs
- PromptStyle.cs
- HierarchicalDataTemplate.cs
- QilBinary.cs
- FrameworkElementFactory.cs
- TextRunCacheImp.cs
- SafeFileMapViewHandle.cs
- MatrixConverter.cs
- GroupJoinQueryOperator.cs
- SafeNativeMethods.cs
- ToolStripItemRenderEventArgs.cs
- EditorZoneBase.cs
- SystemGatewayIPAddressInformation.cs
- XmlSchemaAppInfo.cs
- EtwTrace.cs
- WindowsAuthenticationEventArgs.cs
- TableLayoutPanelResizeGlyph.cs
- Query.cs
- Module.cs
- validation.cs