Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlSortKey.cs
- SqlMethodAttribute.cs
- LinqDataSourceValidationException.cs
- NodeInfo.cs
- SoapSchemaExporter.cs
- DockPanel.cs
- DeleteHelper.cs
- StringWriter.cs
- SafeNativeMethods.cs
- SqlDataSourceCommandEventArgs.cs
- TransformedBitmap.cs
- DesignTimeTemplateParser.cs
- LeafCellTreeNode.cs
- XamlInt32CollectionSerializer.cs
- SafeHandles.cs
- WebRequestModuleElement.cs
- Timer.cs
- FormsAuthenticationUser.cs
- WebPartEventArgs.cs
- SafeViewOfFileHandle.cs
- GiveFeedbackEvent.cs
- TextTreeNode.cs
- DescendantBaseQuery.cs
- SynchronizationValidator.cs
- ApplicationGesture.cs
- DBConcurrencyException.cs
- __ComObject.cs
- Switch.cs
- InternalSafeNativeMethods.cs
- ConfigXmlComment.cs
- RuntimeHandles.cs
- RegexStringValidatorAttribute.cs
- shaperfactory.cs
- DocumentEventArgs.cs
- UserMapPath.cs
- DynamicValidatorEventArgs.cs
- DataGridViewRowHeaderCell.cs
- FactoryMaker.cs
- XmlComplianceUtil.cs
- ArrayElementGridEntry.cs
- WebSysDisplayNameAttribute.cs
- BaseDataBoundControlDesigner.cs
- SQLChars.cs
- InternalCache.cs
- ServiceOperationParameter.cs
- EntityDataSourceEntitySetNameItem.cs
- RsaSecurityKey.cs
- InternalException.cs
- validation.cs
- StringConverter.cs
- RuntimeWrappedException.cs
- StickyNoteHelper.cs
- DataServiceRequestOfT.cs
- EntityViewGenerator.cs
- PolicyStatement.cs
- FixedSchema.cs
- SqlColumnizer.cs
- MailFileEditor.cs
- WebPartDisplayModeCollection.cs
- LookupNode.cs
- ReadOnlyMetadataCollection.cs
- WebResourceAttribute.cs
- GlobalAllocSafeHandle.cs
- DragDrop.cs
- SizeF.cs
- HwndSourceKeyboardInputSite.cs
- FontStretch.cs
- WinEventQueueItem.cs
- OutputCacheSettingsSection.cs
- Buffer.cs
- InkCanvasSelectionAdorner.cs
- PageBuildProvider.cs
- GlobalProxySelection.cs
- TreeViewItem.cs
- IgnoreFlushAndCloseStream.cs
- PostBackTrigger.cs
- GeneralTransform.cs
- PropertyPanel.cs
- TabControlEvent.cs
- UnsafeNetInfoNativeMethods.cs
- DecimalFormatter.cs
- FixedStringLookup.cs
- SizeKeyFrameCollection.cs
- CommandTreeTypeHelper.cs
- KeyConstraint.cs
- FacetDescriptionElement.cs
- ListContractAdapter.cs
- HtmlImage.cs
- UIAgentAsyncParams.cs
- Matrix.cs
- ToolboxItemImageConverter.cs
- OdbcUtils.cs
- GridViewRow.cs
- SubtreeProcessor.cs
- DockingAttribute.cs
- ReflectEventDescriptor.cs
- FixedSOMTextRun.cs
- DynamicVirtualDiscoSearcher.cs
- HtmlTableRowCollection.cs
- CqlGenerator.cs