Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Misc / CompatibleIComparer.cs / 1 / 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
- SerializationEventsCache.cs
- EnumMember.cs
- MetadataWorkspace.cs
- TypeUnloadedException.cs
- SpAudioStreamWrapper.cs
- Container.cs
- RenderTargetBitmap.cs
- ListBindingHelper.cs
- LayoutEditorPart.cs
- ValidatorCompatibilityHelper.cs
- AsymmetricAlgorithm.cs
- OptionalColumn.cs
- LicenseProviderAttribute.cs
- Random.cs
- AuthenticateEventArgs.cs
- TimerElapsedEvenArgs.cs
- PropertyDescriptors.cs
- TextTreeUndo.cs
- ProcessInfo.cs
- ButtonColumn.cs
- AddInContractAttribute.cs
- EventArgs.cs
- EventProviderWriter.cs
- WriteableOnDemandPackagePart.cs
- EntityTypeEmitter.cs
- MetadataFile.cs
- NotifyIcon.cs
- CacheEntry.cs
- handlecollector.cs
- GridToolTip.cs
- ToolStripScrollButton.cs
- EnvironmentPermission.cs
- StrokeNodeOperations2.cs
- DataGridViewRowsAddedEventArgs.cs
- Selection.cs
- RuntimeResourceSet.cs
- HostingEnvironmentException.cs
- ProfileGroupSettings.cs
- DbConnectionPoolOptions.cs
- _ConnectOverlappedAsyncResult.cs
- ToolBarButton.cs
- SHA256Managed.cs
- WebServiceErrorEvent.cs
- LogWriteRestartAreaState.cs
- PrimitiveXmlSerializers.cs
- ImageFormat.cs
- CommandManager.cs
- PersonalizablePropertyEntry.cs
- SerializerDescriptor.cs
- ClientBuildManagerCallback.cs
- StateDesigner.LayoutSelectionGlyph.cs
- DebugInfo.cs
- HttpListenerPrefixCollection.cs
- DictionarySectionHandler.cs
- XamlVector3DCollectionSerializer.cs
- RelationshipDetailsRow.cs
- XmlDataFileEditor.cs
- SchemaDeclBase.cs
- CodeGeneratorOptions.cs
- BuildProvider.cs
- DbMetaDataColumnNames.cs
- CngKey.cs
- OverlappedAsyncResult.cs
- __Filters.cs
- Emitter.cs
- KeyProperty.cs
- RewritingProcessor.cs
- BaseTemplateParser.cs
- RegexCharClass.cs
- IIS7UserPrincipal.cs
- GrowingArray.cs
- GridView.cs
- SettingsAttributeDictionary.cs
- DataBindingHandlerAttribute.cs
- NetTcpSecurityElement.cs
- PropertyTabChangedEvent.cs
- NodeFunctions.cs
- BlobPersonalizationState.cs
- SiteIdentityPermission.cs
- ReverseComparer.cs
- Visual3D.cs
- COM2ICategorizePropertiesHandler.cs
- AnonymousIdentificationModule.cs
- ToolboxComponentsCreatingEventArgs.cs
- TextShapeableCharacters.cs
- SqlVisitor.cs
- ActivityInterfaces.cs
- TagElement.cs
- AbandonedMutexException.cs
- ColumnTypeConverter.cs
- BinaryObjectWriter.cs
- XsdDuration.cs
- XmlQueryCardinality.cs
- HashStream.cs
- WebServiceParameterData.cs
- AvTrace.cs
- OpenTypeCommon.cs
- ProviderUtil.cs
- StyleHelper.cs
- parserscommon.cs