Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Util / SymbolEqualComparer.cs / 1 / 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. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //[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. // Copyright (c) Microsoft Corporation. All rights reserved.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PagedDataSource.cs
- StateRuntime.cs
- AsyncResult.cs
- PrtCap_Public_Simple.cs
- SetIterators.cs
- StringAttributeCollection.cs
- UnSafeCharBuffer.cs
- EntityDataSourceStatementEditor.cs
- ImmutableAssemblyCacheEntry.cs
- HuffModule.cs
- ContentPlaceHolder.cs
- SharedTcpTransportManager.cs
- PropertyManager.cs
- RetriableClipboard.cs
- SrgsRulesCollection.cs
- SpanIndex.cs
- DataGridViewRowCancelEventArgs.cs
- Point4D.cs
- XPathAncestorIterator.cs
- RequiredFieldValidator.cs
- LineMetrics.cs
- StyleCollection.cs
- BindableTemplateBuilder.cs
- Misc.cs
- PresentationSource.cs
- StringExpressionSet.cs
- DataGridViewRowPostPaintEventArgs.cs
- PixelFormat.cs
- CheckoutException.cs
- xsdvalidator.cs
- RectAnimation.cs
- OSFeature.cs
- GridViewRowEventArgs.cs
- MouseGesture.cs
- SafeTimerHandle.cs
- ProxyFragment.cs
- ReadOnlyKeyedCollection.cs
- DocumentPageTextView.cs
- ControlOperationInvoker.cs
- DbResourceAllocator.cs
- GatewayDefinition.cs
- FolderNameEditor.cs
- CommandHelper.cs
- CannotUnloadAppDomainException.cs
- TypedDatasetGenerator.cs
- DataFieldConverter.cs
- SafeHandle.cs
- Crc32Helper.cs
- DynamicPhysicalDiscoSearcher.cs
- TraceProvider.cs
- TransformProviderWrapper.cs
- BitmapMetadataBlob.cs
- Int32KeyFrameCollection.cs
- AppSettingsReader.cs
- ChildrenQuery.cs
- VerticalAlignConverter.cs
- ConfigViewGenerator.cs
- UnknownExceptionActionHelper.cs
- Filter.cs
- DesignerVerb.cs
- XsltQilFactory.cs
- TypeConstant.cs
- Duration.cs
- WmlListAdapter.cs
- ResourceWriter.cs
- RegexWorker.cs
- TextEndOfSegment.cs
- SqlDependency.cs
- EventLog.cs
- DataBinding.cs
- ColorAnimationUsingKeyFrames.cs
- SqlComparer.cs
- SqlEnums.cs
- NotFiniteNumberException.cs
- DataGridViewAutoSizeModeEventArgs.cs
- ToolStripRenderEventArgs.cs
- SimpleHandlerFactory.cs
- MinMaxParagraphWidth.cs
- HttpFileCollectionWrapper.cs
- Bitmap.cs
- UnhandledExceptionEventArgs.cs
- QueryOutputWriterV1.cs
- TextBounds.cs
- SectionUpdates.cs
- TrackingMemoryStream.cs
- ObjectDataSourceStatusEventArgs.cs
- QueryAccessibilityHelpEvent.cs
- ValueUtilsSmi.cs
- HtmlButton.cs
- TextDecorations.cs
- IxmlLineInfo.cs
- BaseDataList.cs
- ResourceManagerWrapper.cs
- NavigatorInput.cs
- SizeF.cs
- MouseDevice.cs
- safePerfProviderHandle.cs
- EditingScopeUndoUnit.cs
- PkcsUtils.cs
- DataViewManagerListItemTypeDescriptor.cs