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
- PriorityItem.cs
- DetailsViewInsertEventArgs.cs
- ToolStripRenderer.cs
- ClientRuntimeConfig.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- PropertyItem.cs
- ServiceReference.cs
- ResourceIDHelper.cs
- HttpPostServerProtocol.cs
- CodeGotoStatement.cs
- safelink.cs
- MeasureItemEvent.cs
- FormattedTextSymbols.cs
- ServicePointManager.cs
- SchemaImporterExtension.cs
- Process.cs
- TemplateBuilder.cs
- BrowserCapabilitiesFactoryBase.cs
- ProfilePropertySettings.cs
- XamlWrappingReader.cs
- MessagePropertyFilter.cs
- Behavior.cs
- RawKeyboardInputReport.cs
- HttpChannelFactory.cs
- EdmValidator.cs
- OpacityConverter.cs
- SimpleLine.cs
- SqlMethodCallConverter.cs
- EmptyImpersonationContext.cs
- CompModHelpers.cs
- FileSystemWatcher.cs
- UrlPath.cs
- CollectionConverter.cs
- DataServiceClientException.cs
- SoapProtocolImporter.cs
- PrintDialog.cs
- Propagator.JoinPropagator.cs
- SmiSettersStream.cs
- SemaphoreSecurity.cs
- CorrelationKey.cs
- LocationUpdates.cs
- SQLInt32.cs
- DllNotFoundException.cs
- PropertyMapper.cs
- CssClassPropertyAttribute.cs
- WindowCollection.cs
- regiisutil.cs
- DispatcherExceptionFilterEventArgs.cs
- PasswordRecovery.cs
- HandlerBase.cs
- TraceLog.cs
- HtmlTable.cs
- CompilerWrapper.cs
- MouseWheelEventArgs.cs
- OleDbParameter.cs
- FixedTextBuilder.cs
- ProviderConnectionPointCollection.cs
- BufferedReadStream.cs
- ErrorStyle.cs
- DefaultDiscoveryServiceExtension.cs
- ProtectedConfiguration.cs
- SortExpressionBuilder.cs
- Publisher.cs
- CryptoApi.cs
- MetaModel.cs
- securitycriticaldataClass.cs
- HealthMonitoringSection.cs
- PeerFlooder.cs
- Literal.cs
- WorkflowPersistenceService.cs
- SSmlParser.cs
- XpsImage.cs
- TagMapInfo.cs
- RawUIStateInputReport.cs
- StateWorkerRequest.cs
- DefinitionUpdate.cs
- UnicodeEncoding.cs
- Baml2006ReaderSettings.cs
- TdsParserStaticMethods.cs
- CurrencyManager.cs
- ChameleonKey.cs
- DbProviderConfigurationHandler.cs
- ContainerUIElement3D.cs
- GeometryModel3D.cs
- TextWriter.cs
- ClientScriptItem.cs
- HttpModuleAction.cs
- ToolStripItemCollection.cs
- panel.cs
- XPathDescendantIterator.cs
- MsdtcWrapper.cs
- DirtyTextRange.cs
- BinaryNode.cs
- PolyQuadraticBezierSegment.cs
- EntityParameterCollection.cs
- DescendantQuery.cs
- DrawingAttributes.cs
- WebControlAdapter.cs
- CompensationDesigner.cs
- UpdateRecord.cs