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
- Ops.cs
- PrefixHandle.cs
- datacache.cs
- DataGridAutoFormat.cs
- InputLanguageSource.cs
- Separator.cs
- Floater.cs
- InkPresenterAutomationPeer.cs
- Hashtable.cs
- UTF7Encoding.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- CodeAttachEventStatement.cs
- IgnoreDataMemberAttribute.cs
- Int32.cs
- RootBuilder.cs
- HyperLinkStyle.cs
- XmlHierarchicalEnumerable.cs
- _AuthenticationState.cs
- ScrollBar.cs
- ImageSourceValueSerializer.cs
- CursorInteropHelper.cs
- RequestTimeoutManager.cs
- MessageBuffer.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- DataReaderContainer.cs
- MinimizableAttributeTypeConverter.cs
- GB18030Encoding.cs
- GradientBrush.cs
- FontFamilyConverter.cs
- PropertyEmitter.cs
- ProcessHostServerConfig.cs
- PersonalizationState.cs
- CharacterMetricsDictionary.cs
- DatatypeImplementation.cs
- RoleManagerSection.cs
- SerializationFieldInfo.cs
- Region.cs
- ElementNotEnabledException.cs
- DecimalAnimationBase.cs
- TypedServiceOperationListItem.cs
- HttpStreamXmlDictionaryWriter.cs
- MembershipUser.cs
- CodeAttributeDeclarationCollection.cs
- DiagnosticTraceSource.cs
- SchemaName.cs
- UnauthorizedAccessException.cs
- ScrollableControl.cs
- SqlTransaction.cs
- EventMap.cs
- ButtonFieldBase.cs
- X509Extension.cs
- ColumnResizeAdorner.cs
- UnicodeEncoding.cs
- InvalidCastException.cs
- X509AsymmetricSecurityKey.cs
- TemplatedAdorner.cs
- ExceptionUtility.cs
- ComponentChangedEvent.cs
- RSATokenProvider.cs
- WeakRefEnumerator.cs
- UserControlAutomationPeer.cs
- FixedSOMTableCell.cs
- CodeIterationStatement.cs
- EntityWrapper.cs
- DynamicMethod.cs
- CounterCreationData.cs
- WasAdminWrapper.cs
- DataProtection.cs
- AddingNewEventArgs.cs
- Types.cs
- DataGridTextBoxColumn.cs
- TemplateControlParser.cs
- EntityDescriptor.cs
- DataServiceProviderWrapper.cs
- Transform.cs
- CodeDefaultValueExpression.cs
- MaxValueConverter.cs
- ToolStripSplitButton.cs
- SmtpFailedRecipientsException.cs
- AddressAccessDeniedException.cs
- StreamSecurityUpgradeInitiatorAsyncResult.cs
- CompilerState.cs
- BasicHttpMessageSecurity.cs
- HttpProcessUtility.cs
- XPathSelectionIterator.cs
- EntityDesignerBuildProvider.cs
- ViewCellRelation.cs
- SslStream.cs
- UnauthorizedAccessException.cs
- SchemaElementLookUpTable.cs
- XmlSchemaSimpleContent.cs
- DbCommandDefinition.cs
- TextEditorSelection.cs
- DataGridViewRowsAddedEventArgs.cs
- BevelBitmapEffect.cs
- SchemaObjectWriter.cs
- RemotingConfiguration.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- EpmContentDeSerializerBase.cs
- HttpProfileGroupBase.cs