Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- BidOverLoads.cs
- NetworkInterface.cs
- TableHeaderCell.cs
- PseudoWebRequest.cs
- wpf-etw.cs
- EdmMember.cs
- RouteValueDictionary.cs
- RectangleConverter.cs
- Latin1Encoding.cs
- ValidatingPropertiesEventArgs.cs
- ProfilePropertySettingsCollection.cs
- ListBoxItemAutomationPeer.cs
- UserNamePasswordValidator.cs
- FileSystemWatcher.cs
- Attributes.cs
- HwndHostAutomationPeer.cs
- autovalidator.cs
- XMLSyntaxException.cs
- TableHeaderCell.cs
- XmlTextEncoder.cs
- RelationshipEndMember.cs
- WorkflowFileItem.cs
- OracleMonthSpan.cs
- Crypto.cs
- XmlSchemaRedefine.cs
- TypeConverterAttribute.cs
- mansign.cs
- ControlEvent.cs
- EmissiveMaterial.cs
- EntityObject.cs
- WorkflowWebService.cs
- CodeEntryPointMethod.cs
- DataGridViewRowStateChangedEventArgs.cs
- CheckoutException.cs
- EventMap.cs
- PageCopyCount.cs
- DirectoryInfo.cs
- HttpGetServerProtocol.cs
- SafeFindHandle.cs
- CollectionCodeDomSerializer.cs
- QilNode.cs
- InstanceOwner.cs
- UpdateTranslator.cs
- BulletedListEventArgs.cs
- DropDownButton.cs
- XmlWrappingWriter.cs
- CompoundFileReference.cs
- PerfCounterSection.cs
- CacheMode.cs
- TextMarkerSource.cs
- XComponentModel.cs
- ThreadAttributes.cs
- SliderAutomationPeer.cs
- CompoundFileReference.cs
- LoadedOrUnloadedOperation.cs
- XomlSerializationHelpers.cs
- SafeMemoryMappedFileHandle.cs
- DivideByZeroException.cs
- UnsafeNativeMethodsTablet.cs
- RegularExpressionValidator.cs
- SqlBuilder.cs
- ProcessInputEventArgs.cs
- ForeignKeyConstraint.cs
- NotConverter.cs
- Domain.cs
- NativeCompoundFileAPIs.cs
- DBNull.cs
- PropertyCondition.cs
- SmtpSection.cs
- TextSchema.cs
- Polygon.cs
- ExpressionPrefixAttribute.cs
- PnrpPermission.cs
- ObjectSelectorEditor.cs
- Encoding.cs
- ActivationArguments.cs
- ZoneLinkButton.cs
- ResXDataNode.cs
- DynamicExpression.cs
- WebOperationContext.cs
- EnumBuilder.cs
- GrammarBuilder.cs
- TraceSource.cs
- streamingZipPartStream.cs
- ScriptReferenceEventArgs.cs
- ColorTransform.cs
- HelloOperationAsyncResult.cs
- PathFigureCollectionConverter.cs
- PasswordBox.cs
- ActivitySurrogate.cs
- DesignerGenericWebPart.cs
- Table.cs
- TypeListConverter.cs
- DataGridViewRowEventArgs.cs
- UnsafeNativeMethods.cs
- DataBinding.cs
- StructuredType.cs
- RectangleGeometry.cs
- TextShapeableCharacters.cs
- Msec.cs