Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewColumnCollectionEditor.cs
- HtmlInputControl.cs
- ComponentConverter.cs
- XmlComment.cs
- FlowDocumentPageViewerAutomationPeer.cs
- CodePrimitiveExpression.cs
- EntityDescriptor.cs
- PreservationFileWriter.cs
- CompilerResults.cs
- VisualStyleElement.cs
- FixedNode.cs
- Vector3DCollectionConverter.cs
- TypeDescriptor.cs
- VisualProxy.cs
- Byte.cs
- ButtonField.cs
- SystemWebCachingSectionGroup.cs
- DiagnosticsElement.cs
- ByteAnimation.cs
- SqlReferenceCollection.cs
- KeyTimeConverter.cs
- MasterPageCodeDomTreeGenerator.cs
- ApplicationTrust.cs
- ConnectionPointCookie.cs
- PersistChildrenAttribute.cs
- BulletedList.cs
- NavigationHelper.cs
- ProcessHostConfigUtils.cs
- InternalControlCollection.cs
- PackageRelationshipSelector.cs
- BaseAsyncResult.cs
- XmlSchemaValidator.cs
- Thread.cs
- TextEditorTables.cs
- ChangePassword.cs
- SyntaxCheck.cs
- HandlerBase.cs
- RoleManagerEventArgs.cs
- QilInvoke.cs
- ContentTextAutomationPeer.cs
- ErasingStroke.cs
- ToolStripRendererSwitcher.cs
- CultureTable.cs
- InternalMappingException.cs
- CompModHelpers.cs
- EmptyStringExpandableObjectConverter.cs
- PublisherIdentityPermission.cs
- XmlSerializationGeneratedCode.cs
- FileDialogCustomPlaces.cs
- ByteStreamGeometryContext.cs
- PropertyValidationContext.cs
- HMACRIPEMD160.cs
- AnimationException.cs
- RtfNavigator.cs
- SizeAnimationUsingKeyFrames.cs
- PropertiesTab.cs
- Polyline.cs
- WebPartConnectionsConnectVerb.cs
- ConstraintManager.cs
- BrushValueSerializer.cs
- NTAccount.cs
- TableRowGroup.cs
- MessageQueueConverter.cs
- PolyBezierSegmentFigureLogic.cs
- GridViewCancelEditEventArgs.cs
- util.cs
- MultiSelectRootGridEntry.cs
- DataObjectFieldAttribute.cs
- SerializationSectionGroup.cs
- RectAnimationBase.cs
- DataGrid.cs
- SmtpNegotiateAuthenticationModule.cs
- DataGridViewLayoutData.cs
- TTSVoice.cs
- SerializationObjectManager.cs
- DrawingAttributes.cs
- ItemList.cs
- ErrorProvider.cs
- TrustSection.cs
- Win32SafeHandles.cs
- OdbcFactory.cs
- ICspAsymmetricAlgorithm.cs
- CngProperty.cs
- StreamReader.cs
- _KerberosClient.cs
- XmlReflectionMember.cs
- TypeResolver.cs
- OutputCacheModule.cs
- XmlLanguage.cs
- WaitHandleCannotBeOpenedException.cs
- SqlServices.cs
- RoleManagerSection.cs
- TemplateField.cs
- RegexEditorDialog.cs
- EpmContentDeSerializer.cs
- Permission.cs
- MetaChildrenColumn.cs
- SByteConverter.cs
- KeyValuePair.cs
- TreeNodeCollectionEditorDialog.cs