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
- XamlFigureLengthSerializer.cs
- ObjRef.cs
- Validator.cs
- MemberExpression.cs
- SqlBuffer.cs
- X509SecurityTokenAuthenticator.cs
- XsltFunctions.cs
- XmlSchemaObjectTable.cs
- EntityDesignerDataSourceView.cs
- DmlSqlGenerator.cs
- PointAnimation.cs
- ScaleTransform.cs
- Transform3DGroup.cs
- SemanticResolver.cs
- AdvancedBindingEditor.cs
- TimeSpan.cs
- SimpleFieldTemplateFactory.cs
- SkewTransform.cs
- SafeEventLogReadHandle.cs
- DataGridItemCollection.cs
- ByteStreamMessage.cs
- TemplatedAdorner.cs
- PropertyItemInternal.cs
- OleDbSchemaGuid.cs
- ElementAction.cs
- embossbitmapeffect.cs
- XomlCompilerParameters.cs
- GradientStopCollection.cs
- ExceptionTranslationTable.cs
- DatasetMethodGenerator.cs
- StrongNameMembershipCondition.cs
- ContentPlaceHolderDesigner.cs
- DispatcherExceptionFilterEventArgs.cs
- FlowSwitch.cs
- BindingsCollection.cs
- WebPartCollection.cs
- NetTcpSectionData.cs
- AutoGeneratedFieldProperties.cs
- SqlFlattener.cs
- EventBuilder.cs
- SqlReferenceCollection.cs
- AssociatedControlConverter.cs
- HttpProfileBase.cs
- GenerateScriptTypeAttribute.cs
- CachedTypeface.cs
- XPathAncestorQuery.cs
- EarlyBoundInfo.cs
- SystemMulticastIPAddressInformation.cs
- MulticastNotSupportedException.cs
- BamlLocalizer.cs
- MsmqIntegrationValidationBehavior.cs
- FormsAuthenticationTicket.cs
- NetSectionGroup.cs
- CqlLexer.cs
- CollectionViewGroupInternal.cs
- ConnectionModeReader.cs
- FormViewInsertEventArgs.cs
- QilPatternFactory.cs
- EntitySetBaseCollection.cs
- SqlTrackingWorkflowInstance.cs
- ChtmlTextWriter.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ProgressBarRenderer.cs
- QueryCacheManager.cs
- DataServiceRequestException.cs
- WebPartExportVerb.cs
- RightsManagementEncryptedStream.cs
- shaperfactoryquerycacheentry.cs
- EnumValidator.cs
- HttpModuleCollection.cs
- Literal.cs
- IISMapPath.cs
- WinCategoryAttribute.cs
- IncrementalReadDecoders.cs
- ManipulationStartedEventArgs.cs
- ReaderContextStackData.cs
- TextTreeTextNode.cs
- GridViewRow.cs
- KeyPressEvent.cs
- DocumentGridContextMenu.cs
- AuthenticationManager.cs
- MemberInfoSerializationHolder.cs
- InternalDispatchObject.cs
- MemoryMappedViewAccessor.cs
- Comparer.cs
- PeoplePickerWrapper.cs
- TextTreeFixupNode.cs
- XmlImplementation.cs
- PinnedBufferMemoryStream.cs
- UInt16Storage.cs
- OracleLob.cs
- WindowsPen.cs
- _ListenerResponseStream.cs
- RTTrackingProfile.cs
- ValidationEventArgs.cs
- SpellerHighlightLayer.cs
- Enlistment.cs
- AnnotationHelper.cs
- MSAAEventDispatcher.cs
- ResourceManagerWrapper.cs