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
- ObjectStateManager.cs
- _BasicClient.cs
- TextBoxBase.cs
- InputBindingCollection.cs
- EventLevel.cs
- Vector3DAnimationBase.cs
- InteropEnvironment.cs
- XhtmlTextWriter.cs
- ConvertEvent.cs
- NullableDecimalAverageAggregationOperator.cs
- NullableConverter.cs
- _SpnDictionary.cs
- ListenUriMode.cs
- ClickablePoint.cs
- WindowsListViewItemStartMenu.cs
- DesignerActionItemCollection.cs
- BindableAttribute.cs
- RegistryPermission.cs
- ResXResourceWriter.cs
- StructuredTypeEmitter.cs
- AppDomainManager.cs
- GridViewRowEventArgs.cs
- EntityDataSourceState.cs
- FtpCachePolicyElement.cs
- BaseTemplateCodeDomTreeGenerator.cs
- DataGridViewSortCompareEventArgs.cs
- DynamicPropertyReader.cs
- DataGridCommandEventArgs.cs
- TextEffectCollection.cs
- AccessViolationException.cs
- NaturalLanguageHyphenator.cs
- RegexMatchCollection.cs
- TableLayoutStyleCollection.cs
- XmlSchemaValidationException.cs
- TransformValueSerializer.cs
- FormViewPagerRow.cs
- OleDbEnumerator.cs
- BufferedStream.cs
- CompilerGeneratedAttribute.cs
- CompilationSection.cs
- SQLDoubleStorage.cs
- ActiveDocumentEvent.cs
- ViewGenResults.cs
- EmissiveMaterial.cs
- InputProcessorProfilesLoader.cs
- StylusTip.cs
- HtmlElementEventArgs.cs
- HttpResponseHeader.cs
- AnnotationHighlightLayer.cs
- TypedReference.cs
- SqlCommandSet.cs
- IsolatedStorageFileStream.cs
- ContractType.cs
- ClientData.cs
- Latin1Encoding.cs
- SequenceDesigner.cs
- TypeBuilderInstantiation.cs
- WebAdminConfigurationHelper.cs
- InternalBufferOverflowException.cs
- CompressStream.cs
- RuleSettingsCollection.cs
- EventBookmark.cs
- controlskin.cs
- JsonFormatWriterGenerator.cs
- PreviewPrintController.cs
- ImageDesigner.cs
- ClientTarget.cs
- DbParameterCollection.cs
- InputLangChangeEvent.cs
- FlowDocumentReader.cs
- BasicHttpMessageSecurity.cs
- ObjectPersistData.cs
- Dispatcher.cs
- RuleSetCollection.cs
- DataSvcMapFile.cs
- AspNetSynchronizationContext.cs
- FlagsAttribute.cs
- SchemaImporter.cs
- EnvironmentPermission.cs
- DataRecordObjectView.cs
- ConfigurationSectionCollection.cs
- validationstate.cs
- AlternateView.cs
- IArgumentProvider.cs
- MenuAutomationPeer.cs
- QilPatternFactory.cs
- ModelFunctionTypeElement.cs
- SystemIPv4InterfaceProperties.cs
- XpsResourceDictionary.cs
- DataGridViewCellValueEventArgs.cs
- ProfilePropertyNameValidator.cs
- SmiXetterAccessMap.cs
- MimeBasePart.cs
- SqlXml.cs
- WebPartDisplayModeEventArgs.cs
- SigningProgress.cs
- TextEmbeddedObject.cs
- SmtpReplyReaderFactory.cs
- AxHost.cs
- SecurityDescriptor.cs