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
- MoveSizeWinEventHandler.cs
- HtmlTableCellCollection.cs
- PolicyUnit.cs
- EventLogPermissionEntryCollection.cs
- ApplicationTrust.cs
- StronglyTypedResourceBuilder.cs
- XmlSchemaObjectCollection.cs
- OleDbParameterCollection.cs
- XmlSerializationGeneratedCode.cs
- BasicBrowserDialog.cs
- ArraySubsetEnumerator.cs
- InvalidEnumArgumentException.cs
- WebPartHeaderCloseVerb.cs
- MachineKeyConverter.cs
- ButtonStandardAdapter.cs
- CapabilitiesState.cs
- XslAstAnalyzer.cs
- ToolStripContentPanelDesigner.cs
- SqlCommandAsyncResult.cs
- GeometryModel3D.cs
- SynchronizingStream.cs
- NamespaceInfo.cs
- BrushValueSerializer.cs
- CompositeActivityMarkupSerializer.cs
- XmlSchemaSimpleContent.cs
- AttributeExtensions.cs
- ModelUIElement3D.cs
- MutexSecurity.cs
- ActionItem.cs
- RangeValidator.cs
- DbParameterHelper.cs
- WebBrowserDocumentCompletedEventHandler.cs
- Soap12ProtocolReflector.cs
- embossbitmapeffect.cs
- DbConnectionOptions.cs
- GregorianCalendarHelper.cs
- MetadataArtifactLoaderResource.cs
- ImagingCache.cs
- PowerModeChangedEventArgs.cs
- ImageIndexEditor.cs
- ValidatingReaderNodeData.cs
- ManipulationStartingEventArgs.cs
- OrderedDictionaryStateHelper.cs
- ItemChangedEventArgs.cs
- StringAnimationBase.cs
- PreviewKeyDownEventArgs.cs
- XmlNamedNodeMap.cs
- ExtensionElementCollection.cs
- PolyQuadraticBezierSegment.cs
- HwndAppCommandInputProvider.cs
- XmlSchemaException.cs
- PageAsyncTaskManager.cs
- TdsParser.cs
- VirtualizingPanel.cs
- DeclarativeCatalogPart.cs
- VirtualPathProvider.cs
- ScrollPatternIdentifiers.cs
- querybuilder.cs
- EventEntry.cs
- FormParameter.cs
- DependentTransaction.cs
- Model3D.cs
- PageAsyncTaskManager.cs
- XdrBuilder.cs
- OdbcConnectionStringbuilder.cs
- RegexCharClass.cs
- InputManager.cs
- InputElement.cs
- EventProxy.cs
- MethodCallTranslator.cs
- NetworkStream.cs
- XmlSchemaAnnotated.cs
- Drawing.cs
- NetSectionGroup.cs
- OleDbErrorCollection.cs
- TypedTableBaseExtensions.cs
- FormViewUpdatedEventArgs.cs
- GregorianCalendarHelper.cs
- TCEAdapterGenerator.cs
- IntermediatePolicyValidator.cs
- _SafeNetHandles.cs
- PlatformCulture.cs
- ObjectTag.cs
- BaseInfoTable.cs
- ReceiveActivityDesignerTheme.cs
- FontWeights.cs
- NullReferenceException.cs
- VoiceInfo.cs
- CroppedBitmap.cs
- Pair.cs
- AsyncPostBackErrorEventArgs.cs
- SqlNodeAnnotations.cs
- WCFServiceClientProxyGenerator.cs
- MasterPageCodeDomTreeGenerator.cs
- AnyReturnReader.cs
- XamlBuildTaskServices.cs
- WebResponse.cs
- PeerHelpers.cs
- SqlFlattener.cs
- DayRenderEvent.cs