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
- MemberListBinding.cs
- XmlKeywords.cs
- ObjectList.cs
- Tuple.cs
- httpstaticobjectscollection.cs
- QueryException.cs
- RewritingPass.cs
- AdapterDictionary.cs
- SchemaImporterExtension.cs
- OuterGlowBitmapEffect.cs
- LoginName.cs
- CatalogZoneAutoFormat.cs
- ProviderUtil.cs
- documentsequencetextcontainer.cs
- TextAction.cs
- RawContentTypeMapper.cs
- StorageRoot.cs
- XamlReaderHelper.cs
- XPathException.cs
- __FastResourceComparer.cs
- DataComponentGenerator.cs
- CompoundFileIOPermission.cs
- XmlSchemaAppInfo.cs
- Classification.cs
- DataGridViewCellValueEventArgs.cs
- BrowserInteropHelper.cs
- InputProcessorProfilesLoader.cs
- WebEvents.cs
- FaultBookmark.cs
- HtmlControlPersistable.cs
- BinHexDecoder.cs
- uribuilder.cs
- WindowsListViewGroupSubsetLink.cs
- XmlDictionaryWriter.cs
- SpAudioStreamWrapper.cs
- Label.cs
- AdapterDictionary.cs
- ProxyWebPartConnectionCollection.cs
- LoginAutoFormat.cs
- DynamicEndpointElement.cs
- XmlSchemaExternal.cs
- CalendarDateChangedEventArgs.cs
- _StreamFramer.cs
- UniqueIdentifierService.cs
- NameSpaceExtractor.cs
- HttpListenerResponse.cs
- DbParameterHelper.cs
- CallbackException.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- RoutedUICommand.cs
- DataMemberConverter.cs
- SafePointer.cs
- TrackingLocation.cs
- WebMethodAttribute.cs
- XmlRootAttribute.cs
- PageBreakRecord.cs
- FunctionUpdateCommand.cs
- HtmlDocument.cs
- WhereQueryOperator.cs
- SmiRequestExecutor.cs
- StatusBar.cs
- EntityDataSourceEntityTypeFilterItem.cs
- dtdvalidator.cs
- SessionStateUtil.cs
- CursorConverter.cs
- ImageClickEventArgs.cs
- MemberRelationshipService.cs
- ProcessInfo.cs
- DetailsViewInsertEventArgs.cs
- FixedBufferAttribute.cs
- AssemblyAttributes.cs
- ControlTemplate.cs
- SizeValueSerializer.cs
- SqlFactory.cs
- SqlFileStream.cs
- XmlFormatReaderGenerator.cs
- Rule.cs
- ServerValidateEventArgs.cs
- TraceUtils.cs
- SkewTransform.cs
- IdentityManager.cs
- RecordBuilder.cs
- LinqDataSourceValidationException.cs
- NumberFunctions.cs
- InstanceDescriptor.cs
- XmlHierarchicalEnumerable.cs
- ScaleTransform3D.cs
- AuthenticodeSignatureInformation.cs
- NonClientArea.cs
- OleDbRowUpdatingEvent.cs
- Pens.cs
- StandardRuntimeEnumValidatorAttribute.cs
- DictionaryKeyPropertyAttribute.cs
- HttpClientCertificate.cs
- Viewport2DVisual3D.cs
- ExpressionLink.cs
- EventWaitHandle.cs
- DataGridViewColumn.cs
- ExtentCqlBlock.cs
- NativeCppClassAttribute.cs