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
- DBPropSet.cs
- TaskExtensions.cs
- UnSafeCharBuffer.cs
- RegexTree.cs
- GradientBrush.cs
- PassportAuthenticationModule.cs
- SessionIDManager.cs
- WebZone.cs
- ActiveXSite.cs
- CodePropertyReferenceExpression.cs
- MultilineStringConverter.cs
- TogglePatternIdentifiers.cs
- Brush.cs
- FacetValueContainer.cs
- XslVisitor.cs
- TransformGroup.cs
- X509Certificate.cs
- LambdaCompiler.Logical.cs
- WindowsHyperlink.cs
- ElementHost.cs
- ResumeStoryboard.cs
- NativeMethods.cs
- UshortList2.cs
- XmlHierarchicalEnumerable.cs
- Win32Native.cs
- DataKeyCollection.cs
- GridViewAutomationPeer.cs
- Compiler.cs
- TextCollapsingProperties.cs
- BitStream.cs
- PreviewPrintController.cs
- ReliabilityContractAttribute.cs
- EntityCommandExecutionException.cs
- RegistryPermission.cs
- UIInitializationException.cs
- InvalidateEvent.cs
- ImpersonateTokenRef.cs
- DataServiceBehavior.cs
- Button.cs
- EventLogger.cs
- GridSplitter.cs
- WebServicesSection.cs
- TransformConverter.cs
- ReflectTypeDescriptionProvider.cs
- Cursors.cs
- WeakRefEnumerator.cs
- MemberExpressionHelper.cs
- TextViewBase.cs
- XPathScanner.cs
- CategoryGridEntry.cs
- Pen.cs
- SelectionListDesigner.cs
- ThaiBuddhistCalendar.cs
- MouseButtonEventArgs.cs
- UIElementPropertyUndoUnit.cs
- ListView.cs
- COSERVERINFO.cs
- WebPartPersonalization.cs
- cryptoapiTransform.cs
- X509CertificateChain.cs
- TableCellCollection.cs
- PeerObject.cs
- XPathMultyIterator.cs
- Logging.cs
- HTMLTextWriter.cs
- SizeLimitedCache.cs
- RootBrowserWindowAutomationPeer.cs
- CodeDomSerializationProvider.cs
- Expr.cs
- ContainerActivationHelper.cs
- TextAdaptor.cs
- Composition.cs
- UpdateProgress.cs
- TreeNode.cs
- WizardPanel.cs
- MemoryMappedViewStream.cs
- DataObjectFieldAttribute.cs
- BooleanConverter.cs
- ListViewDeletedEventArgs.cs
- NotifyParentPropertyAttribute.cs
- ProviderManager.cs
- NativeMethods.cs
- QuaternionValueSerializer.cs
- RuntimeEnvironment.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- _Rfc2616CacheValidators.cs
- SmtpAuthenticationManager.cs
- VScrollBar.cs
- DelegateSerializationHolder.cs
- OneToOneMappingSerializer.cs
- IgnorePropertiesAttribute.cs
- WebConfigurationManager.cs
- X509CertificateValidator.cs
- VirtualDirectoryMappingCollection.cs
- TextParaLineResult.cs
- PasswordTextNavigator.cs
- XPathException.cs
- MultiPageTextView.cs
- CultureInfoConverter.cs
- ObjectDataSourceDisposingEventArgs.cs