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
- CookieHandler.cs
- MultiBinding.cs
- OdbcConnectionHandle.cs
- TypeSystem.cs
- ReliableSessionElement.cs
- DefaultValueAttribute.cs
- FacetValueContainer.cs
- XmlLanguageConverter.cs
- DecoderFallback.cs
- UIElementHelper.cs
- Zone.cs
- BooleanSwitch.cs
- OneWayElement.cs
- BaseValidator.cs
- RecognizedAudio.cs
- WorkflowMessageEventArgs.cs
- GZipObjectSerializer.cs
- TextTreePropertyUndoUnit.cs
- MissingFieldException.cs
- AtomParser.cs
- AsymmetricSignatureDeformatter.cs
- XmlSerializer.cs
- ServiceSecurityContext.cs
- BaseTemplateBuildProvider.cs
- ConcurrentQueue.cs
- SafeNativeMethods.cs
- FigureParagraph.cs
- XmlEncodedRawTextWriter.cs
- PipelineComponent.cs
- DataGridViewColumnStateChangedEventArgs.cs
- DesignTimeParseData.cs
- PenThreadPool.cs
- contentDescriptor.cs
- Light.cs
- RegionInfo.cs
- BitmapEffectCollection.cs
- StrongNameMembershipCondition.cs
- COM2IDispatchConverter.cs
- FixedSOMLineRanges.cs
- ObjectQueryProvider.cs
- CriticalExceptions.cs
- VisualTreeUtils.cs
- Compensate.cs
- nulltextcontainer.cs
- X509Chain.cs
- ECDsa.cs
- Binding.cs
- PageWrapper.cs
- WebProxyScriptElement.cs
- RadioButton.cs
- PropertiesTab.cs
- Byte.cs
- FlowDecision.cs
- DataColumnChangeEvent.cs
- Type.cs
- AuthenticationException.cs
- ListViewCommandEventArgs.cs
- AnimatedTypeHelpers.cs
- XomlDesignerLoader.cs
- CryptoApi.cs
- ExpressionTextBoxAutomationPeer.cs
- AssertSection.cs
- StorageRoot.cs
- RSAOAEPKeyExchangeFormatter.cs
- Menu.cs
- HttpApplicationFactory.cs
- UrlUtility.cs
- DoubleCollectionValueSerializer.cs
- DataMemberFieldEditor.cs
- BinaryObjectWriter.cs
- DispatcherOperation.cs
- GradientStop.cs
- UriTemplateCompoundPathSegment.cs
- TracedNativeMethods.cs
- SynchronizedDispatch.cs
- DiagnosticTrace.cs
- XmlEnumAttribute.cs
- Size3D.cs
- XmlSchemaSimpleContent.cs
- HelpEvent.cs
- SmtpSection.cs
- DataGridState.cs
- WindowsListBox.cs
- VirtualDirectoryMapping.cs
- Encoder.cs
- FileChangesMonitor.cs
- ProcessHostFactoryHelper.cs
- NavigationWindowAutomationPeer.cs
- BasicKeyConstraint.cs
- VectorConverter.cs
- PeerInputChannelListener.cs
- AxImporter.cs
- FixedStringLookup.cs
- Selector.cs
- CrossContextChannel.cs
- TagPrefixCollection.cs
- PropertyEmitter.cs
- ListItemsPage.cs
- ControlParameter.cs
- EdgeProfileValidation.cs