Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ //// 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
- LinkClickEvent.cs
- PolyBezierSegmentFigureLogic.cs
- CodeTypeMemberCollection.cs
- httpserverutility.cs
- SpecularMaterial.cs
- ToolStripComboBox.cs
- DBSchemaRow.cs
- MultilineStringConverter.cs
- InstanceDescriptor.cs
- VerticalAlignConverter.cs
- BitHelper.cs
- SimpleExpression.cs
- ConfigurationSettings.cs
- DocumentPageHost.cs
- SkewTransform.cs
- DataList.cs
- Int32CollectionConverter.cs
- DesignerToolStripControlHost.cs
- DNS.cs
- AutoScrollHelper.cs
- MsmqInputChannelBase.cs
- BmpBitmapEncoder.cs
- DetailsViewModeEventArgs.cs
- DropSource.cs
- HttpServerChannel.cs
- VectorValueSerializer.cs
- MenuItemStyleCollection.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- SafeRightsManagementHandle.cs
- HelpKeywordAttribute.cs
- PropertyItem.cs
- DebugHandleTracker.cs
- CodeChecksumPragma.cs
- ExpressionNormalizer.cs
- ParentQuery.cs
- NamespaceQuery.cs
- QuestionEventArgs.cs
- DataGridBoolColumn.cs
- _ProxyChain.cs
- FormViewRow.cs
- CacheRequest.cs
- SqlConnectionString.cs
- __Filters.cs
- CacheForPrimitiveTypes.cs
- CatalogZoneDesigner.cs
- ManagementExtension.cs
- InheritedPropertyChangedEventArgs.cs
- DataGridItemCollection.cs
- PropertyItem.cs
- TextSegment.cs
- ArrayElementGridEntry.cs
- BinaryWriter.cs
- ApplicationFileCodeDomTreeGenerator.cs
- MembershipValidatePasswordEventArgs.cs
- LayoutInformation.cs
- ImmutableObjectAttribute.cs
- CodeParameterDeclarationExpressionCollection.cs
- JsonGlobals.cs
- IisTraceWebEventProvider.cs
- PreloadedPackages.cs
- MemberPathMap.cs
- webproxy.cs
- IConvertible.cs
- SerializableAttribute.cs
- MenuItem.cs
- _HelperAsyncResults.cs
- CngUIPolicy.cs
- ItemContainerPattern.cs
- CustomPopupPlacement.cs
- NativeMethodsOther.cs
- ArraySegment.cs
- TrackingConditionCollection.cs
- ValidatedControlConverter.cs
- EdmSchemaAttribute.cs
- Matrix3D.cs
- PostBackOptions.cs
- ControlsConfig.cs
- OdbcEnvironment.cs
- IDispatchConstantAttribute.cs
- Token.cs
- XmlSerializerFactory.cs
- ListViewItem.cs
- TripleDESCryptoServiceProvider.cs
- DataGridViewRowCancelEventArgs.cs
- RawStylusSystemGestureInputReport.cs
- TextPointer.cs
- NumberFormatInfo.cs
- ToolStripLabel.cs
- TextEmbeddedObject.cs
- InstanceLockQueryResult.cs
- CharacterHit.cs
- SQLBinaryStorage.cs
- AutomationAttributeInfo.cs
- WsdlParser.cs
- MarginsConverter.cs
- StrongName.cs
- UdpTransportSettingsElement.cs
- FrameworkElement.cs
- ProviderSettings.cs
- AdPostCacheSubstitution.cs