Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / XPathMessageFilterElementComparer.cs / 1 / XPathMessageFilterElementComparer.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Configuration { using System; using System.ServiceModel.Dispatcher; using System.Collections; using System.Text; using System.Xml; public class XPathMessageFilterElementComparer : IComparer { #region IComparer Members int IComparer.Compare(object x, object y) { string elementKey1 = TranslateObjectToElementKey(x); string elementKey2 = TranslateObjectToElementKey(y); return String.Compare(elementKey1, elementKey2, StringComparison.Ordinal); } #endregion internal static string ParseXPathString(XPathMessageFilter filter) { return XPathMessageFilterElementComparer.ParseXPathString(filter, false); } internal static string ParseXPathString(XPathMessageFilter filter, bool throwOnFailure) { XPathLexer lexer = new XPathLexer(filter.XPath); return XPathMessageFilterElementComparer.ParseXPathString(lexer, filter.Namespaces, throwOnFailure); } static string ParseXPathString(XPathLexer lexer, XmlNamespaceManager namespaceManager, bool throwOnFailure) { string retVal = String.Empty; int currentTokenStart = lexer.FirstTokenChar; if (lexer.MoveNext()) { XPathToken token = lexer.Token; StringBuilder xPathString = new StringBuilder(XPathMessageFilterElementComparer.ParseXPathString(lexer, namespaceManager, throwOnFailure)); if (XPathTokenID.NameTest == token.TokenID) { string nsPrefix = token.Prefix; if (!String.IsNullOrEmpty(nsPrefix)) { string ns = namespaceManager.LookupNamespace(nsPrefix); if (!String.IsNullOrEmpty(ns)) { xPathString = xPathString.Replace(nsPrefix, ns, currentTokenStart, nsPrefix.Length); } else { if (throwOnFailure) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new IndexOutOfRangeException(SR.GetString(SR.ConfigXPathNamespacePrefixNotFound, nsPrefix))); } } } } retVal = xPathString.ToString(); } else { retVal = lexer.ConsumedSubstring(); } return retVal; } string TranslateObjectToElementKey(object obj) { string elementKey = null; if (obj.GetType().IsAssignableFrom(typeof(XPathMessageFilter))) { elementKey = XPathMessageFilterElementComparer.ParseXPathString((XPathMessageFilter)obj); } else if (obj.GetType().IsAssignableFrom(typeof(XPathMessageFilterElement))) { elementKey = XPathMessageFilterElementComparer.ParseXPathString(((XPathMessageFilterElement)obj).Filter); } else if (obj.GetType().IsAssignableFrom(typeof(string))) { elementKey = (string)obj; } if (String.IsNullOrEmpty(elementKey)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.ConfigCannotParseXPathFilter, obj.GetType().AssemblyQualifiedName))); } return elementKey; } } } // 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
- UpdatePanel.cs
- ObjectRef.cs
- InvalidCastException.cs
- DataFieldConverter.cs
- WSFederationHttpSecurityMode.cs
- RowSpanVector.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ToolBarOverflowPanel.cs
- ScanQueryOperator.cs
- CollectionViewSource.cs
- XPathAxisIterator.cs
- DrawingContext.cs
- InstanceData.cs
- UIServiceHelper.cs
- TemplatedMailWebEventProvider.cs
- UnsafeNativeMethodsTablet.cs
- ReliableMessagingVersionConverter.cs
- ElementUtil.cs
- DefaultBinder.cs
- SettingsSavedEventArgs.cs
- DetailsViewInsertedEventArgs.cs
- VectorAnimation.cs
- FileIOPermission.cs
- BooleanStorage.cs
- BookmarkOptionsHelper.cs
- NavigationProgressEventArgs.cs
- FullTrustAssemblyCollection.cs
- ProxyWebPartConnectionCollection.cs
- PolicyAssertionCollection.cs
- AttachedPropertiesService.cs
- AccessDataSourceView.cs
- PrintControllerWithStatusDialog.cs
- HighlightVisual.cs
- XPathSelectionIterator.cs
- RegistryExceptionHelper.cs
- UiaCoreApi.cs
- XmlSchemaValidationException.cs
- X509ClientCertificateAuthenticationElement.cs
- XPathNode.cs
- MessageBox.cs
- DataGridTable.cs
- SimpleType.cs
- RectAnimationBase.cs
- SqlConnectionFactory.cs
- MatrixKeyFrameCollection.cs
- ExpressionParser.cs
- ExtensionSimplifierMarkupObject.cs
- KeyboardNavigation.cs
- SqlBulkCopy.cs
- BitmapEffectOutputConnector.cs
- CacheVirtualItemsEvent.cs
- Literal.cs
- relpropertyhelper.cs
- LoadedOrUnloadedOperation.cs
- ComponentResourceKey.cs
- CAGDesigner.cs
- HttpListenerPrefixCollection.cs
- GeneralTransform3DTo2D.cs
- SqlDataRecord.cs
- KeyEventArgs.cs
- CatalogPartChrome.cs
- WebDescriptionAttribute.cs
- MediaCommands.cs
- PassportAuthenticationModule.cs
- TransformGroup.cs
- DiscoveryDocument.cs
- WebPartConnectionsConnectVerb.cs
- EtwTrace.cs
- WindowsScrollBar.cs
- HasCopySemanticsAttribute.cs
- Decorator.cs
- WebPartPersonalization.cs
- Util.cs
- NativeMethodsCLR.cs
- Separator.cs
- NavigationFailedEventArgs.cs
- ConfigurationSettings.cs
- CancellationHandlerDesigner.cs
- NamespaceList.cs
- FormatterServices.cs
- SrgsToken.cs
- validationstate.cs
- XmlElement.cs
- PrintDialog.cs
- ReferentialConstraint.cs
- FilePrompt.cs
- URI.cs
- DataGridViewComboBoxCell.cs
- ToolStripContainer.cs
- BrowserDefinitionCollection.cs
- HoistedLocals.cs
- RedBlackList.cs
- __FastResourceComparer.cs
- BypassElementCollection.cs
- SecurityManager.cs
- DesignerAttributeInfo.cs
- ArrayWithOffset.cs
- CornerRadiusConverter.cs
- DoubleCollectionValueSerializer.cs
- Queue.cs