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
- WebRequestModuleElementCollection.cs
- UnsafeNativeMethods.cs
- OdbcEnvironment.cs
- MenuAdapter.cs
- LingerOption.cs
- AspCompat.cs
- PropertyTabChangedEvent.cs
- FileUtil.cs
- SynchronizedInputAdaptor.cs
- PinnedBufferMemoryStream.cs
- DefaultTraceListener.cs
- ExtendedPropertyCollection.cs
- TableLayoutCellPaintEventArgs.cs
- TripleDES.cs
- Base64Encoder.cs
- PasswordTextNavigator.cs
- X509ChainPolicy.cs
- SmtpFailedRecipientsException.cs
- RuntimeVariablesExpression.cs
- LocalClientSecuritySettings.cs
- RuntimeArgumentHandle.cs
- HasCopySemanticsAttribute.cs
- BitmapSizeOptions.cs
- JavaScriptSerializer.cs
- PhoneCallDesigner.cs
- ProtocolViolationException.cs
- ProviderUtil.cs
- Inline.cs
- BrowserCapabilitiesCompiler.cs
- PeerTransportElement.cs
- RepeaterItemCollection.cs
- SafeViewOfFileHandle.cs
- TypeUtil.cs
- _Connection.cs
- DataControlLinkButton.cs
- AutomationEventArgs.cs
- RegistryKey.cs
- ValueHandle.cs
- HtmlSelect.cs
- InvalidProgramException.cs
- RangeValidator.cs
- CharacterMetrics.cs
- CommandLibraryHelper.cs
- TableProviderWrapper.cs
- ExpanderAutomationPeer.cs
- CheckPair.cs
- UICuesEvent.cs
- StopStoryboard.cs
- RadialGradientBrush.cs
- SolidBrush.cs
- RMEnrollmentPage1.cs
- ConfigurationValues.cs
- OleDbParameterCollection.cs
- PasswordDeriveBytes.cs
- GridToolTip.cs
- WindowsStartMenu.cs
- XmlElementAttribute.cs
- ProviderSettingsCollection.cs
- TabRenderer.cs
- Polyline.cs
- IndicShape.cs
- documentation.cs
- GC.cs
- GacUtil.cs
- URLAttribute.cs
- HelpExampleGenerator.cs
- Endpoint.cs
- DrawingGroup.cs
- TextServicesProperty.cs
- HostedTransportConfigurationBase.cs
- QueryContinueDragEvent.cs
- SqlProvider.cs
- LinkClickEvent.cs
- ReadOnlyHierarchicalDataSource.cs
- XmlArrayAttribute.cs
- FixedSOMPage.cs
- RuntimeVariableList.cs
- Span.cs
- Utilities.cs
- SmtpException.cs
- SqlWriter.cs
- ThemeInfoAttribute.cs
- MsmqChannelListenerBase.cs
- TemplateContentLoader.cs
- PeerPresenceInfo.cs
- ThumbAutomationPeer.cs
- SettingsPropertyIsReadOnlyException.cs
- CollectionView.cs
- DesignTimeTemplateParser.cs
- DeploymentExceptionMapper.cs
- FixedSOMPageConstructor.cs
- PerformanceCounterLib.cs
- HandleExceptionArgs.cs
- SatelliteContractVersionAttribute.cs
- FixedPosition.cs
- EdmValidator.cs
- FormsAuthenticationCredentials.cs
- GlyphCache.cs
- ControlAdapter.cs
- EpmContentSerializer.cs