Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / CaseInsensitiveComparer.cs / 1305376 / CaseInsensitiveComparer.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CaseInsensitiveComparer ** **[....] ** ** ** ============================================================*/ namespace System.Collections { //This class does not contain members and does not need to be serializable using System; using System.Collections; using System.Globalization; using System.Diagnostics.Contracts; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] public class CaseInsensitiveComparer : IComparer { private CompareInfo m_compareInfo; private static CaseInsensitiveComparer m_InvariantCaseInsensitiveComparer; public CaseInsensitiveComparer() { m_compareInfo = CultureInfo.CurrentCulture.CompareInfo; } public CaseInsensitiveComparer(CultureInfo culture) { if (culture==null) { throw new ArgumentNullException("culture"); } Contract.EndContractBlock(); m_compareInfo = culture.CompareInfo; } public static CaseInsensitiveComparer Default { get { Contract.Ensures(Contract.Result() != null); return new CaseInsensitiveComparer(CultureInfo.CurrentCulture); } } public static CaseInsensitiveComparer DefaultInvariant { get { Contract.Ensures(Contract.Result () != null); if (m_InvariantCaseInsensitiveComparer == null) { m_InvariantCaseInsensitiveComparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture); } return m_InvariantCaseInsensitiveComparer; } } // Behaves exactly like Comparer.Default.Compare except that the comparison is case insensitive // Compares two Objects by calling CompareTo. If a == // b,0 is returned. If a implements // IComparable, a.CompareTo(b) is returned. If a // doesn't implement IComparable and b does, // -(b.CompareTo(a)) is returned, otherwise an // exception is thrown. // public int Compare(Object a, Object b) { String sa = a as String; String sb = b as String; if (sa != null && sb != null) return m_compareInfo.Compare(sa, sb, CompareOptions.IgnoreCase); else return Comparer.Default.Compare(a,b); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CaseInsensitiveComparer ** ** [....] ** ** ** ============================================================*/ namespace System.Collections { //This class does not contain members and does not need to be serializable using System; using System.Collections; using System.Globalization; using System.Diagnostics.Contracts; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] public class CaseInsensitiveComparer : IComparer { private CompareInfo m_compareInfo; private static CaseInsensitiveComparer m_InvariantCaseInsensitiveComparer; public CaseInsensitiveComparer() { m_compareInfo = CultureInfo.CurrentCulture.CompareInfo; } public CaseInsensitiveComparer(CultureInfo culture) { if (culture==null) { throw new ArgumentNullException("culture"); } Contract.EndContractBlock(); m_compareInfo = culture.CompareInfo; } public static CaseInsensitiveComparer Default { get { Contract.Ensures(Contract.Result() != null); return new CaseInsensitiveComparer(CultureInfo.CurrentCulture); } } public static CaseInsensitiveComparer DefaultInvariant { get { Contract.Ensures(Contract.Result () != null); if (m_InvariantCaseInsensitiveComparer == null) { m_InvariantCaseInsensitiveComparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture); } return m_InvariantCaseInsensitiveComparer; } } // Behaves exactly like Comparer.Default.Compare except that the comparison is case insensitive // Compares two Objects by calling CompareTo. If a == // b,0 is returned. If a implements // IComparable, a.CompareTo(b) is returned. If a // doesn't implement IComparable and b does, // -(b.CompareTo(a)) is returned, otherwise an // exception is thrown. // public int Compare(Object a, Object b) { String sa = a as String; String sb = b as String; if (sa != null && sb != null) return m_compareInfo.Compare(sa, sb, CompareOptions.IgnoreCase); else return Comparer.Default.Compare(a,b); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WorkflowDurableInstance.cs
- ETagAttribute.cs
- StatusBar.cs
- Logging.cs
- AttributeAction.cs
- WebBrowserContainer.cs
- Transform3DGroup.cs
- BinaryFormatterWriter.cs
- ObjectHandle.cs
- DataRecord.cs
- IdentityValidationException.cs
- MenuItemStyleCollection.cs
- FixUp.cs
- SystemColors.cs
- XPathDocumentNavigator.cs
- SiteMapNode.cs
- WebPartCatalogAddVerb.cs
- XmlFormatWriterGenerator.cs
- SpecularMaterial.cs
- TabPanel.cs
- parserscommon.cs
- PropertyValidationContext.cs
- Main.cs
- PolygonHotSpot.cs
- LexicalChunk.cs
- FlowDocumentPage.cs
- RemotingException.cs
- AspNetHostingPermission.cs
- EncryptedKey.cs
- ArcSegment.cs
- CatalogPartCollection.cs
- CqlLexer.cs
- DatatypeImplementation.cs
- FixUpCollection.cs
- SqlUdtInfo.cs
- DataBindingCollection.cs
- ExpressionBinding.cs
- SettingsPropertyWrongTypeException.cs
- InternalBufferOverflowException.cs
- MutableAssemblyCacheEntry.cs
- MappingException.cs
- ProxyFragment.cs
- WorkflowOperationFault.cs
- ToolBarButton.cs
- DefaultAuthorizationContext.cs
- NumericUpDownAcceleration.cs
- ActivityStatusChangeEventArgs.cs
- DirectoryGroupQuery.cs
- DesignTimeData.cs
- HashStream.cs
- TimeoutHelper.cs
- ScrollBar.cs
- ObjectAssociationEndMapping.cs
- StatusBarPanelClickEvent.cs
- DocComment.cs
- FontUnit.cs
- Pair.cs
- TextTreeNode.cs
- DataGridPreparingCellForEditEventArgs.cs
- UIElement3D.cs
- XmlObjectSerializerReadContextComplex.cs
- SmtpClient.cs
- FixedPageAutomationPeer.cs
- EntityDataSourceEntitySetNameItem.cs
- HelpEvent.cs
- SerializationHelper.cs
- RelationshipEndMember.cs
- WebSysDescriptionAttribute.cs
- ListControlBoundActionList.cs
- cache.cs
- WebPartUtil.cs
- SqlColumnizer.cs
- DataSourceSelectArguments.cs
- CodeSubDirectoriesCollection.cs
- ObjectItemAssemblyLoader.cs
- AccessText.cs
- __Error.cs
- NotifyParentPropertyAttribute.cs
- DataSysAttribute.cs
- Constant.cs
- ToolStripSeparator.cs
- UncommonField.cs
- HitTestFilterBehavior.cs
- PolicyLevel.cs
- ValidateNames.cs
- VirtualPathData.cs
- DesignTableCollection.cs
- InfoCardAsymmetricCrypto.cs
- ZoneLinkButton.cs
- ToolStripPanelRow.cs
- AddDataControlFieldDialog.cs
- EncryptedReference.cs
- SizeAnimationBase.cs
- ThreadExceptionEvent.cs
- SharedConnectionInfo.cs
- EntityParameterCollection.cs
- EventDescriptor.cs
- XmlILModule.cs
- X509CertificateValidator.cs
- Debugger.cs