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
- XmlSchemaGroupRef.cs
- BooleanStorage.cs
- VarRemapper.cs
- ParameterModifier.cs
- XmlHierarchicalEnumerable.cs
- BufferedGraphicsManager.cs
- XmlReflectionMember.cs
- QilBinary.cs
- PageCatalogPart.cs
- CodeExpressionStatement.cs
- MustUnderstandBehavior.cs
- RemoteWebConfigurationHostServer.cs
- StringDictionary.cs
- ImageListStreamer.cs
- ChangeProcessor.cs
- FieldBuilder.cs
- ForceCopyBuildProvider.cs
- DataGridViewDataErrorEventArgs.cs
- RijndaelManaged.cs
- Label.cs
- SQLDecimalStorage.cs
- HandleRef.cs
- FrugalMap.cs
- _HTTPDateParse.cs
- BamlWriter.cs
- _LocalDataStore.cs
- ProviderBase.cs
- PathSegment.cs
- XmlHierarchicalEnumerable.cs
- UnmanagedHandle.cs
- SchemaElementDecl.cs
- DbConnectionClosed.cs
- TdsEnums.cs
- SplineQuaternionKeyFrame.cs
- BufferedGraphicsManager.cs
- DocumentReferenceCollection.cs
- CodeMemberMethod.cs
- CompiledXpathExpr.cs
- CannotUnloadAppDomainException.cs
- NullReferenceException.cs
- HttpHandlerActionCollection.cs
- TimerElapsedEvenArgs.cs
- CqlParser.cs
- ProfilePropertySettingsCollection.cs
- BasicExpressionVisitor.cs
- WebPartEditorOkVerb.cs
- DeferredBinaryDeserializerExtension.cs
- CodeDelegateInvokeExpression.cs
- EventProviderWriter.cs
- BaseUriHelper.cs
- TypefaceMap.cs
- RSAPKCS1SignatureDeformatter.cs
- SectionRecord.cs
- CompilerErrorCollection.cs
- NetworkAddressChange.cs
- TableAdapterManagerMethodGenerator.cs
- TaskSchedulerException.cs
- GroupBox.cs
- _FixedSizeReader.cs
- ScalarType.cs
- ManagedIStream.cs
- ButtonChrome.cs
- DecoderFallbackWithFailureFlag.cs
- XmlImplementation.cs
- TripleDES.cs
- Parser.cs
- XPathAxisIterator.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- DoubleAnimationUsingPath.cs
- WithParamAction.cs
- ADMembershipUser.cs
- UnaryExpression.cs
- FunctionParameter.cs
- XmlBinaryReader.cs
- TextRangeSerialization.cs
- PolicyUnit.cs
- DES.cs
- TableStyle.cs
- BasicExpressionVisitor.cs
- TreeNodeCollection.cs
- RepeaterItem.cs
- IndexObject.cs
- OutputCacheProfileCollection.cs
- ContainerActivationHelper.cs
- CommonServiceBehaviorElement.cs
- SystemEvents.cs
- CryptoHandle.cs
- ApplicationTrust.cs
- DriveNotFoundException.cs
- TextServicesContext.cs
- NameSpaceEvent.cs
- SignatureConfirmationElement.cs
- XmlSchemaAll.cs
- WebPartCollection.cs
- TaskbarItemInfo.cs
- SqlFormatter.cs
- MsmqBindingElementBase.cs
- DisableDpiAwarenessAttribute.cs
- RuntimeEnvironment.cs
- MessageSecurityOverTcp.cs