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
- SystemUnicastIPAddressInformation.cs
- SrgsGrammar.cs
- autovalidator.cs
- HtmlInputImage.cs
- FullTextState.cs
- StateMachineExecutionState.cs
- LinearGradientBrush.cs
- CodeGroup.cs
- COM2ColorConverter.cs
- SkinBuilder.cs
- EntityDataSourceSelectedEventArgs.cs
- XmlNavigatorStack.cs
- TreeNodeStyleCollectionEditor.cs
- SmiEventStream.cs
- Parser.cs
- ListControl.cs
- MediaContext.cs
- GenericIdentity.cs
- XmlSchemaAny.cs
- ConfigXmlCDataSection.cs
- IFlowDocumentViewer.cs
- PageStatePersister.cs
- LogicalTreeHelper.cs
- ScaleTransform.cs
- UiaCoreApi.cs
- RsaSecurityToken.cs
- AspNetPartialTrustHelpers.cs
- ScrollBarAutomationPeer.cs
- ToolStripDropDownItem.cs
- SqlCommandBuilder.cs
- DocumentXmlWriter.cs
- TextSelectionHighlightLayer.cs
- DecoderNLS.cs
- CuspData.cs
- BitmapMetadata.cs
- PenLineCapValidation.cs
- PathFigure.cs
- HttpChannelHelpers.cs
- NTAccount.cs
- RawUIStateInputReport.cs
- ISessionStateStore.cs
- PartitionResolver.cs
- Matrix.cs
- WindowsListView.cs
- HtmlLink.cs
- EdmProviderManifest.cs
- SecurityChannelListener.cs
- SerializationHelper.cs
- ActiveXHost.cs
- FragmentQueryKB.cs
- LinqDataSourceContextEventArgs.cs
- comcontractssection.cs
- ProgramPublisher.cs
- ButtonBaseAdapter.cs
- ExclusiveTcpTransportManager.cs
- GridItemCollection.cs
- DefinitionUpdate.cs
- Baml2006SchemaContext.cs
- JapaneseCalendar.cs
- SizeConverter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- RoutedUICommand.cs
- DefaultObjectMappingItemCollection.cs
- ComplexObject.cs
- iisPickupDirectory.cs
- DomainConstraint.cs
- Serializer.cs
- AttachedPropertyMethodSelector.cs
- HyperLinkField.cs
- BigIntegerStorage.cs
- CollectionType.cs
- SiteOfOriginContainer.cs
- OutputCacheSettings.cs
- AudioFileOut.cs
- LabelAutomationPeer.cs
- EndEvent.cs
- StylusTip.cs
- SettingsPropertyNotFoundException.cs
- BinaryNode.cs
- Connector.cs
- ISAPIApplicationHost.cs
- MemberPathMap.cs
- DataGrid.cs
- ComplexType.cs
- SiteIdentityPermission.cs
- ImageListImageEditor.cs
- WindowsPen.cs
- AttributeCollection.cs
- DataServiceRequestOfT.cs
- XmlIlGenerator.cs
- Types.cs
- KeyInterop.cs
- HttpStaticObjectsCollectionWrapper.cs
- ScanQueryOperator.cs
- InputMethod.cs
- StatusBar.cs
- AsyncOperationManager.cs
- DbDataRecord.cs
- SymLanguageVendor.cs
- PolyLineSegment.cs