Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Misc / CompatibleIComparer.cs / 1305376 / CompatibleIComparer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * This class is used to create hashcodes that are Everett Compatible. * * Copyright (c) 2004 Microsoft Corporation */ namespace System.Collections.Specialized { using Microsoft.Win32; using System.Collections; using System.Runtime.Serialization; using System.Globalization; internal class BackCompatibleStringComparer : IEqualityComparer { static internal IEqualityComparer Default = new BackCompatibleStringComparer(); internal BackCompatibleStringComparer() { } //This comes from VS# 434837 and is specifically written to get backcompat public static int GetHashCode(string obj) { unsafe { fixed (char* src = obj) { int hash = 5381; int c; char* szStr = src; while ((c = *szStr) != 0) { hash = ((hash << 5) + hash) ^ c; ++szStr; } return hash; } } } bool IEqualityComparer.Equals(Object a, Object b) { return Object.Equals(a, b); } public virtual int GetHashCode(Object o) { String obj = o as string; if (obj == null) { return o.GetHashCode(); } return BackCompatibleStringComparer.GetHashCode(obj); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * This class is used to create hashcodes that are Everett Compatible. * * Copyright (c) 2004 Microsoft Corporation */ namespace System.Collections.Specialized { using Microsoft.Win32; using System.Collections; using System.Runtime.Serialization; using System.Globalization; internal class BackCompatibleStringComparer : IEqualityComparer { static internal IEqualityComparer Default = new BackCompatibleStringComparer(); internal BackCompatibleStringComparer() { } //This comes from VS# 434837 and is specifically written to get backcompat public static int GetHashCode(string obj) { unsafe { fixed (char* src = obj) { int hash = 5381; int c; char* szStr = src; while ((c = *szStr) != 0) { hash = ((hash << 5) + hash) ^ c; ++szStr; } return hash; } } } bool IEqualityComparer.Equals(Object a, Object b) { return Object.Equals(a, b); } public virtual int GetHashCode(Object o) { String obj = o as string; if (obj == null) { return o.GetHashCode(); } return BackCompatibleStringComparer.GetHashCode(obj); } } } // 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
- FrameDimension.cs
- CommonXSendMessage.cs
- StringArrayConverter.cs
- FormViewDeletedEventArgs.cs
- TableRowCollection.cs
- ZipIORawDataFileBlock.cs
- HandleCollector.cs
- BitHelper.cs
- ISAPIApplicationHost.cs
- ResolveCriteria.cs
- Error.cs
- nulltextcontainer.cs
- BaseValidator.cs
- Decoder.cs
- RoutedCommand.cs
- CryptoKeySecurity.cs
- SrgsElementFactory.cs
- TextFindEngine.cs
- ContainerFilterService.cs
- UnknownBitmapEncoder.cs
- MimeTypePropertyAttribute.cs
- HostUtils.cs
- ToolStripSeparatorRenderEventArgs.cs
- XsltLibrary.cs
- PersianCalendar.cs
- MainMenu.cs
- ValidatingCollection.cs
- PrintPageEvent.cs
- StringAnimationBase.cs
- StylusPointCollection.cs
- CalloutQueueItem.cs
- EnumerableRowCollectionExtensions.cs
- FlagPanel.cs
- WindowsUpDown.cs
- HttpHandlerAction.cs
- CodeComment.cs
- _ServiceNameStore.cs
- ListDataHelper.cs
- FaultPropagationRecord.cs
- PrinterSettings.cs
- HandleCollector.cs
- OneOfTypeConst.cs
- XmlSchemaAppInfo.cs
- SymLanguageVendor.cs
- ProfessionalColors.cs
- SqlOuterApplyReducer.cs
- SHA384Managed.cs
- RelationshipEndMember.cs
- TemplateLookupAction.cs
- Inflater.cs
- COSERVERINFO.cs
- ConfigurationValues.cs
- RootDesignerSerializerAttribute.cs
- ChannelSinkStacks.cs
- ReceiveErrorHandling.cs
- DirectionalAction.cs
- HttpPostedFile.cs
- KnownTypes.cs
- Label.cs
- CodeSnippetExpression.cs
- DataGridViewIntLinkedList.cs
- InputEventArgs.cs
- HelpFileFileNameEditor.cs
- HtmlInputReset.cs
- ParallelTimeline.cs
- BitVector32.cs
- ViewgenContext.cs
- TextContainerChangeEventArgs.cs
- XmlReader.cs
- CommandBindingCollection.cs
- Thread.cs
- CorrelationExtension.cs
- ExtendedPropertyCollection.cs
- UserInitiatedNavigationPermission.cs
- JapaneseLunisolarCalendar.cs
- PagesChangedEventArgs.cs
- ProtocolsSection.cs
- ExpressionNormalizer.cs
- EntityDescriptor.cs
- Delay.cs
- InstancePersistenceException.cs
- ISCIIEncoding.cs
- OdbcConnectionPoolProviderInfo.cs
- nulltextcontainer.cs
- ProtocolsSection.cs
- SerializableAttribute.cs
- ProcessHostFactoryHelper.cs
- ExpressionVisitorHelpers.cs
- SingleSelectRootGridEntry.cs
- XmlAttributeAttribute.cs
- FormViewPagerRow.cs
- StateRuntime.cs
- AttributeAction.cs
- OrderedHashRepartitionStream.cs
- GraphicsContext.cs
- GatewayDefinition.cs
- IndexOutOfRangeException.cs
- GroupAggregateExpr.cs
- ItemsControlAutomationPeer.cs
- Light.cs