Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- CacheEntry.cs
- ValidationHelpers.cs
- TextDecorationCollection.cs
- IDReferencePropertyAttribute.cs
- FlowDocumentPage.cs
- DataSourceXmlSubItemAttribute.cs
- ZipIOLocalFileHeader.cs
- XmlJsonWriter.cs
- DynamicUpdateCommand.cs
- PersonalizableAttribute.cs
- UserControl.cs
- UpdatePanelTriggerCollection.cs
- SamlDelegatingWriter.cs
- EdmProperty.cs
- Timer.cs
- ScalarOps.cs
- OperationPickerDialog.cs
- Command.cs
- DoubleLinkList.cs
- TokenCreationParameter.cs
- Attributes.cs
- SqlCacheDependencySection.cs
- StandardTransformFactory.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ErrorStyle.cs
- BuilderElements.cs
- XmlValueConverter.cs
- DataMemberConverter.cs
- DependencyPropertyValueSerializer.cs
- AxHost.cs
- PatternMatchRules.cs
- ParameterModifier.cs
- EntityWrapper.cs
- WhereQueryOperator.cs
- ReflectionHelper.cs
- FrameworkObject.cs
- login.cs
- HtmlInputControl.cs
- SimpleRecyclingCache.cs
- FlowDecisionDesigner.xaml.cs
- HttpModuleCollection.cs
- TextMarkerSource.cs
- WsdlWriter.cs
- EventLogPermissionEntry.cs
- DataGridViewLayoutData.cs
- XmlFileEditor.cs
- IntSecurity.cs
- HeaderElement.cs
- ImageFormat.cs
- TextServicesCompartmentEventSink.cs
- HwndSubclass.cs
- HtmlSelect.cs
- FormatSelectingMessageInspector.cs
- ScriptingAuthenticationServiceSection.cs
- FormCollection.cs
- RequestBringIntoViewEventArgs.cs
- ActivityExecutor.cs
- TerminatorSinks.cs
- SurrogateEncoder.cs
- XmlJsonReader.cs
- GridToolTip.cs
- List.cs
- XamlSerializerUtil.cs
- ContextStaticAttribute.cs
- TemplateDefinition.cs
- PublishLicense.cs
- RegistryConfigurationProvider.cs
- OleDbStruct.cs
- CodeDirectoryCompiler.cs
- SqlInfoMessageEvent.cs
- IIS7UserPrincipal.cs
- unitconverter.cs
- RtType.cs
- XsltOutput.cs
- RedirectionProxy.cs
- RolePrincipal.cs
- MediaScriptCommandRoutedEventArgs.cs
- BookmarkScopeManager.cs
- SoapProtocolImporter.cs
- PostBackOptions.cs
- HMACSHA384.cs
- _UriTypeConverter.cs
- SqlInfoMessageEvent.cs
- ReadWriteObjectLock.cs
- FixedTextPointer.cs
- RelOps.cs
- ServicesUtilities.cs
- SQLStringStorage.cs
- PackageDigitalSignatureManager.cs
- DataControlCommands.cs
- XmlUtil.cs
- SByteConverter.cs
- DataListItemCollection.cs
- XmlFormatExtensionPrefixAttribute.cs
- ObjectCloneHelper.cs
- Console.cs
- RIPEMD160.cs
- UserControl.cs
- DoneReceivingAsyncResult.cs
- WebSysDisplayNameAttribute.cs