Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / MS / Internal / Data / XmlNodeComparer.cs / 1 / XmlNodeComparer.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Defines XmlNodeComparer object, used to sort a view of data produced by an XmlDataSource. // // Specs: http://avalon/connecteddata/M5%20Specs/UIBinding.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Xml; using MS.Internal.Data; namespace MS.Internal.Data { ////// The XmlNodeComparer is used to sort a view of data produced by an XmlDataSource. /// internal class XmlNodeComparer : IComparer { ////// Constructor. /// /// array of sort parameters /// namespace manager, to control queries /// culture to use for comparisons internal XmlNodeComparer(SortDescriptionCollection sortParameters, XmlNamespaceManager namespaceManager, CultureInfo culture) { _sortParameters = sortParameters; _namespaceManager = namespaceManager; _culture = (culture == null) ? CultureInfo.InvariantCulture : culture; } int IComparer.Compare(object o1, object o2) { int result = 0; XmlNode node1 = o1 as XmlNode; XmlNode node2 = o2 as XmlNode; if (node1 == null) return -1; if (node2 == null) return +1; for (int k = 0; k < _sortParameters.Count; ++k) { string valueX = XmlHelper.SelectStringValue(node1, _sortParameters[k].PropertyName, _namespaceManager); string valueY = XmlHelper.SelectStringValue(node2, _sortParameters[k].PropertyName, _namespaceManager); result = String.Compare(valueX, valueY, false, _culture); if (_sortParameters[k].Direction == ListSortDirection.Descending) result = -result; if (result != 0) break; } return result; } private SortDescriptionCollection _sortParameters; private XmlNamespaceManager _namespaceManager; CultureInfo _culture; } } // 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. // // // Description: Defines XmlNodeComparer object, used to sort a view of data produced by an XmlDataSource. // // Specs: http://avalon/connecteddata/M5%20Specs/UIBinding.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Xml; using MS.Internal.Data; namespace MS.Internal.Data { ////// The XmlNodeComparer is used to sort a view of data produced by an XmlDataSource. /// internal class XmlNodeComparer : IComparer { ////// Constructor. /// /// array of sort parameters /// namespace manager, to control queries /// culture to use for comparisons internal XmlNodeComparer(SortDescriptionCollection sortParameters, XmlNamespaceManager namespaceManager, CultureInfo culture) { _sortParameters = sortParameters; _namespaceManager = namespaceManager; _culture = (culture == null) ? CultureInfo.InvariantCulture : culture; } int IComparer.Compare(object o1, object o2) { int result = 0; XmlNode node1 = o1 as XmlNode; XmlNode node2 = o2 as XmlNode; if (node1 == null) return -1; if (node2 == null) return +1; for (int k = 0; k < _sortParameters.Count; ++k) { string valueX = XmlHelper.SelectStringValue(node1, _sortParameters[k].PropertyName, _namespaceManager); string valueY = XmlHelper.SelectStringValue(node2, _sortParameters[k].PropertyName, _namespaceManager); result = String.Compare(valueX, valueY, false, _culture); if (_sortParameters[k].Direction == ListSortDirection.Descending) result = -result; if (result != 0) break; } return result; } private SortDescriptionCollection _sortParameters; private XmlNamespaceManager _namespaceManager; CultureInfo _culture; } } // 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
- TextUtf8RawTextWriter.cs
- ServiceSecurityAuditBehavior.cs
- BamlVersionHeader.cs
- TcpClientSocketManager.cs
- ValidationResult.cs
- PublisherIdentityPermission.cs
- HMAC.cs
- RbTree.cs
- XPathDocument.cs
- ImageButton.cs
- NonBatchDirectoryCompiler.cs
- DoubleLink.cs
- SqlRecordBuffer.cs
- NotFiniteNumberException.cs
- Selection.cs
- MenuCommandsChangedEventArgs.cs
- BitmapCodecInfo.cs
- DictionaryBase.cs
- TokenBasedSet.cs
- WebUtil.cs
- ModifierKeysConverter.cs
- QilChoice.cs
- TextRange.cs
- DSACryptoServiceProvider.cs
- MDIWindowDialog.cs
- ServiceEndpointElementCollection.cs
- OleDbReferenceCollection.cs
- EmptyReadOnlyDictionaryInternal.cs
- TransactionManager.cs
- WindowsTab.cs
- altserialization.cs
- TreeNodeMouseHoverEvent.cs
- MessageVersion.cs
- EditorZoneBase.cs
- RuntimeCompatibilityAttribute.cs
- SQLResource.cs
- XmlUrlEditor.cs
- ColorConverter.cs
- ParameterDataSourceExpression.cs
- InvalidTimeZoneException.cs
- TextRangeAdaptor.cs
- ListBindingHelper.cs
- OutOfMemoryException.cs
- XmlSchemaCollection.cs
- DrawingAttributesDefaultValueFactory.cs
- _LocalDataStoreMgr.cs
- ToolStripItemClickedEventArgs.cs
- CustomError.cs
- StorageModelBuildProvider.cs
- ValueQuery.cs
- PowerEase.cs
- WindowsNonControl.cs
- EdmType.cs
- EncryptedData.cs
- DbProviderServices.cs
- AdornedElementPlaceholder.cs
- ZipIOLocalFileDataDescriptor.cs
- InvalidEnumArgumentException.cs
- StorageMappingFragment.cs
- BooleanKeyFrameCollection.cs
- ReadOnlyNameValueCollection.cs
- ListItemsPage.cs
- FrameworkElementFactory.cs
- ViewStateException.cs
- DeploymentSection.cs
- XmlObjectSerializerWriteContextComplex.cs
- ConfigUtil.cs
- OdbcEnvironmentHandle.cs
- UnauthorizedWebPart.cs
- ToolboxComponentsCreatingEventArgs.cs
- CalendarDay.cs
- RepeatBehaviorConverter.cs
- ServiceReference.cs
- BaseCodeDomTreeGenerator.cs
- ClientProxyGenerator.cs
- PartialClassGenerationTask.cs
- AsymmetricAlgorithm.cs
- UTF8Encoding.cs
- OptimalTextSource.cs
- TheQuery.cs
- IntranetCredentialPolicy.cs
- ConfigurationStrings.cs
- Table.cs
- UnsafeNetInfoNativeMethods.cs
- ModuleConfigurationInfo.cs
- PolyQuadraticBezierSegment.cs
- BuildProvidersCompiler.cs
- Image.cs
- ToolStrip.cs
- ResourceManager.cs
- XmlDataSourceNodeDescriptor.cs
- IntranetCredentialPolicy.cs
- ErrorFormatterPage.cs
- Pair.cs
- XXXOnTypeBuilderInstantiation.cs
- KeyboardEventArgs.cs
- SessionStateItemCollection.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ListParaClient.cs
- DrawingGroupDrawingContext.cs