Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SymbolEqualComparer.cs / 1305376 / SymbolEqualComparer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Util { using System.Collections; using System.Globalization; ////// internal class SymbolEqualComparer: IComparer { ////// For internal use only. This implements a comparison that only /// checks for equalilty, so this should only be used in un-sorted data /// structures like Hastable and ListDictionary. This is a little faster /// than using CaseInsensitiveComparer because it does a strict character by /// character equality chech rather than a sorted comparison. /// ////// internal static readonly IComparer Default = new SymbolEqualComparer(); internal SymbolEqualComparer() { } int IComparer.Compare(object keyLeft, object keyRight) { string sLeft = keyLeft as string; string sRight = keyRight as string; if (sLeft == null) { throw new ArgumentNullException("keyLeft"); } if (sRight == null) { throw new ArgumentNullException("keyRight"); } int lLeft = sLeft.Length; int lRight = sRight.Length; if (lLeft != lRight) { return 1; } for (int i = 0; i < lLeft; i++) { char charLeft = sLeft[i]; char charRight = sRight[i]; if (charLeft == charRight) { continue; } UnicodeCategory catLeft = Char.GetUnicodeCategory(charLeft); UnicodeCategory catRight = Char.GetUnicodeCategory(charRight); if (catLeft == UnicodeCategory.UppercaseLetter && catRight == UnicodeCategory.LowercaseLetter) { if (Char.ToLower(charLeft, CultureInfo.InvariantCulture) == charRight) { continue; } } else if (catRight == UnicodeCategory.UppercaseLetter && catLeft == UnicodeCategory.LowercaseLetter){ if (Char.ToLower(charRight, CultureInfo.InvariantCulture) == charLeft) { continue; } } return 1; } return 0; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Util { using System.Collections; using System.Globalization; ////// internal class SymbolEqualComparer: IComparer { ////// For internal use only. This implements a comparison that only /// checks for equalilty, so this should only be used in un-sorted data /// structures like Hastable and ListDictionary. This is a little faster /// than using CaseInsensitiveComparer because it does a strict character by /// character equality chech rather than a sorted comparison. /// ////// internal static readonly IComparer Default = new SymbolEqualComparer(); internal SymbolEqualComparer() { } int IComparer.Compare(object keyLeft, object keyRight) { string sLeft = keyLeft as string; string sRight = keyRight as string; if (sLeft == null) { throw new ArgumentNullException("keyLeft"); } if (sRight == null) { throw new ArgumentNullException("keyRight"); } int lLeft = sLeft.Length; int lRight = sRight.Length; if (lLeft != lRight) { return 1; } for (int i = 0; i < lLeft; i++) { char charLeft = sLeft[i]; char charRight = sRight[i]; if (charLeft == charRight) { continue; } UnicodeCategory catLeft = Char.GetUnicodeCategory(charLeft); UnicodeCategory catRight = Char.GetUnicodeCategory(charRight); if (catLeft == UnicodeCategory.UppercaseLetter && catRight == UnicodeCategory.LowercaseLetter) { if (Char.ToLower(charLeft, CultureInfo.InvariantCulture) == charRight) { continue; } } else if (catRight == UnicodeCategory.UppercaseLetter && catLeft == UnicodeCategory.LowercaseLetter){ if (Char.ToLower(charRight, CultureInfo.InvariantCulture) == charLeft) { continue; } } return 1; } return 0; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigurationManagerHelper.cs
- GenericArgumentsUpdater.cs
- MarshalByValueComponent.cs
- IgnoreSection.cs
- SelectedCellsChangedEventArgs.cs
- GotoExpression.cs
- Row.cs
- AssemblyEvidenceFactory.cs
- Serializer.cs
- AppModelKnownContentFactory.cs
- ControlPropertyNameConverter.cs
- CopyNodeSetAction.cs
- JpegBitmapDecoder.cs
- UInt32.cs
- BindingCollection.cs
- DesignerCalendarAdapter.cs
- CrossAppDomainChannel.cs
- ImportContext.cs
- LinkedList.cs
- XmlSchemaAnnotation.cs
- BindingManagerDataErrorEventArgs.cs
- PropertyChangingEventArgs.cs
- SchemaConstraints.cs
- TypefaceMetricsCache.cs
- Int16KeyFrameCollection.cs
- ListItemCollection.cs
- SoapObjectInfo.cs
- SpeakInfo.cs
- TranslateTransform.cs
- RunWorkerCompletedEventArgs.cs
- CheckBoxPopupAdapter.cs
- CacheChildrenQuery.cs
- UnmanagedMemoryStream.cs
- AdornerDecorator.cs
- NullableConverter.cs
- Cloud.cs
- FormsAuthenticationUser.cs
- PaginationProgressEventArgs.cs
- PropertyHelper.cs
- EncryptedType.cs
- HttpGetProtocolImporter.cs
- DataGridViewSelectedColumnCollection.cs
- Terminate.cs
- TableRow.cs
- BuildProviderAppliesToAttribute.cs
- ArraySubsetEnumerator.cs
- SqlNodeAnnotations.cs
- StorageTypeMapping.cs
- FormsAuthenticationUserCollection.cs
- ContextMarshalException.cs
- HttpHandlersSection.cs
- Point3DConverter.cs
- Stopwatch.cs
- ButtonChrome.cs
- followingquery.cs
- DocumentViewerHelper.cs
- OleDbInfoMessageEvent.cs
- DirectoryNotFoundException.cs
- Brush.cs
- EntityDataSourceValidationException.cs
- SchemaObjectWriter.cs
- TimeoutValidationAttribute.cs
- TypeLoadException.cs
- SqlDataSourceTableQuery.cs
- VoiceObjectToken.cs
- ClientBase.cs
- BitStream.cs
- ToolStripSeparator.cs
- XmlLanguageConverter.cs
- RtType.cs
- AuthenticationModuleElementCollection.cs
- SequentialUshortCollection.cs
- KeyNotFoundException.cs
- SystemFonts.cs
- ResourceWriter.cs
- BufferedGraphics.cs
- CharacterShapingProperties.cs
- CursorConverter.cs
- Error.cs
- NameObjectCollectionBase.cs
- ModelItemCollection.cs
- BinHexDecoder.cs
- WebUtil.cs
- DataGridViewSelectedColumnCollection.cs
- XmlSchemaSimpleTypeList.cs
- ClientScriptManagerWrapper.cs
- XmlBindingWorker.cs
- TogglePatternIdentifiers.cs
- WindowsHyperlink.cs
- PropertyCollection.cs
- _ScatterGatherBuffers.cs
- TransformedBitmap.cs
- IntSecurity.cs
- LogConverter.cs
- LocalBuilder.cs
- RoutedCommand.cs
- SizeIndependentAnimationStorage.cs
- DataRow.cs
- Debug.cs
- XPathSelectionIterator.cs