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;
///
///
/// 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 class SymbolEqualComparer: IComparer {
///
/// [To be supplied.]
///
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.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Util {
using System.Collections;
using System.Globalization;
///
///
/// 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 class SymbolEqualComparer: IComparer {
///
/// [To be supplied.]
///
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ActivityUtilities.cs
- GroupBoxRenderer.cs
- COAUTHINFO.cs
- Root.cs
- ClientSettingsSection.cs
- ObjectAnimationUsingKeyFrames.cs
- XmlSchemaSet.cs
- querybuilder.cs
- HashLookup.cs
- KnownBoxes.cs
- ObfuscationAttribute.cs
- SQLSingle.cs
- ToolStripContentPanel.cs
- PersistChildrenAttribute.cs
- DynamicPropertyHolder.cs
- ConnectionPoolRegistry.cs
- DataBoundControlAdapter.cs
- HtmlProps.cs
- ToolStripContextMenu.cs
- DataSetUtil.cs
- KeyConstraint.cs
- HostAdapter.cs
- XmlEntityReference.cs
- QuotedPrintableStream.cs
- CounterCreationDataConverter.cs
- BinaryObjectWriter.cs
- SoundPlayerAction.cs
- ScaleTransform.cs
- InvalidEnumArgumentException.cs
- DataServiceRequestArgs.cs
- StatusBar.cs
- TextCollapsingProperties.cs
- HtmlInputCheckBox.cs
- _StreamFramer.cs
- CachedFontFace.cs
- PlatformNotSupportedException.cs
- AsyncPostBackErrorEventArgs.cs
- NamedPipeWorkerProcess.cs
- ShapingWorkspace.cs
- UITypeEditor.cs
- DbConnectionStringBuilder.cs
- HttpListenerPrefixCollection.cs
- SynchronizedInputHelper.cs
- SemaphoreSecurity.cs
- RegistryPermission.cs
- MouseGesture.cs
- GreenMethods.cs
- ConnectionDemuxer.cs
- AssemblyCache.cs
- StrokeIntersection.cs
- InheritablePropertyChangeInfo.cs
- OutputCacheProfile.cs
- URL.cs
- StandardCommands.cs
- LineUtil.cs
- odbcmetadatacollectionnames.cs
- DataListItemEventArgs.cs
- VideoDrawing.cs
- PageFunction.cs
- jithelpers.cs
- OutputScopeManager.cs
- MemoryMappedView.cs
- TextParagraphCache.cs
- PackageRelationshipSelector.cs
- FixedPageProcessor.cs
- X509SecurityToken.cs
- LineUtil.cs
- RegexGroup.cs
- DataKeyArray.cs
- CfgParser.cs
- TextBoxAutomationPeer.cs
- EventHandlerService.cs
- StringBuilder.cs
- TreePrinter.cs
- TemplateControl.cs
- FontInfo.cs
- DefaultTextStore.cs
- CharUnicodeInfo.cs
- EventInfo.cs
- ProviderSettingsCollection.cs
- KeyEventArgs.cs
- ColorConvertedBitmap.cs
- WebResponse.cs
- XmlName.cs
- XmlILConstructAnalyzer.cs
- ObjectDataSourceView.cs
- CfgParser.cs
- DocumentPageViewAutomationPeer.cs
- DocumentSequence.cs
- EdmValidator.cs
- SystemWebExtensionsSectionGroup.cs
- ListDataHelper.cs
- Parsers.cs
- OleDbRowUpdatingEvent.cs
- AlternateView.cs
- SamlEvidence.cs
- CredentialCache.cs
- TextParagraph.cs
- _TransmitFileOverlappedAsyncResult.cs
- WebPartManager.cs