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
- PropertyInformation.cs
- WebPartManagerInternals.cs
- StorageEndPropertyMapping.cs
- XXXInfos.cs
- WindowsFormsHelpers.cs
- sqlser.cs
- ButtonColumn.cs
- BitmapEffectCollection.cs
- NativeMethods.cs
- HttpConfigurationSystem.cs
- ExpandedWrapper.cs
- WindowsListViewItem.cs
- AspCompat.cs
- Timer.cs
- DefaultEvaluationContext.cs
- PartialList.cs
- MultiTrigger.cs
- DrawToolTipEventArgs.cs
- TabItemWrapperAutomationPeer.cs
- OleDbConnection.cs
- WriteLine.cs
- CommandManager.cs
- CompilerParameters.cs
- ConfigurationSchemaErrors.cs
- BulletedList.cs
- Container.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- FileDialog_Vista_Interop.cs
- TaskFormBase.cs
- CodeParameterDeclarationExpressionCollection.cs
- CustomWebEventKey.cs
- ImageMetadata.cs
- WarningException.cs
- FamilyTypeface.cs
- AssertFilter.cs
- EnumerableRowCollectionExtensions.cs
- WinFormsComponentEditor.cs
- ConfigurationValidatorAttribute.cs
- HtmlHead.cs
- WeakRefEnumerator.cs
- LiteralLink.cs
- ProjectionCamera.cs
- ObjectTag.cs
- RootProfilePropertySettingsCollection.cs
- PropertyValueUIItem.cs
- DataGridViewRowEventArgs.cs
- GridViewUpdateEventArgs.cs
- PrintPageEvent.cs
- WindowsBrush.cs
- IsolatedStorageFile.cs
- ValidatingCollection.cs
- ErrorRuntimeConfig.cs
- AggregationMinMaxHelpers.cs
- Helpers.cs
- DoubleUtil.cs
- MenuBindingsEditorForm.cs
- TreeBuilderXamlTranslator.cs
- StretchValidation.cs
- EDesignUtil.cs
- ToolStripSystemRenderer.cs
- DebugHandleTracker.cs
- QuaternionAnimation.cs
- SByteStorage.cs
- UnsafeNativeMethodsMilCoreApi.cs
- BindableTemplateBuilder.cs
- NonVisualControlAttribute.cs
- ProxyWebPartManager.cs
- TypographyProperties.cs
- DataServiceHostWrapper.cs
- DataGridTextBox.cs
- TypeDescriptor.cs
- ToolStripDropDownClosedEventArgs.cs
- Directory.cs
- DbConnectionPoolOptions.cs
- XmlDocumentFragment.cs
- ObjectHandle.cs
- AccessDataSourceView.cs
- UIElementPropertyUndoUnit.cs
- ComponentCollection.cs
- XmlCountingReader.cs
- ItemDragEvent.cs
- FactoryMaker.cs
- AnnouncementEventArgs.cs
- OleDbInfoMessageEvent.cs
- TransactionManager.cs
- DataListDesigner.cs
- RelationshipManager.cs
- DataTemplateSelector.cs
- QueryOutputWriter.cs
- ColumnCollection.cs
- ToolTip.cs
- SafeSecurityHandles.cs
- URLMembershipCondition.cs
- HTTPNotFoundHandler.cs
- CodeComment.cs
- Comparer.cs
- LoadMessageLogger.cs
- X509Utils.cs
- ImportContext.cs
- CellCreator.cs