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
- AssemblyHash.cs
- GeometryDrawing.cs
- WizardPanel.cs
- FontResourceCache.cs
- ChangeNode.cs
- ModuleConfigurationInfo.cs
- WebPermission.cs
- ListViewUpdatedEventArgs.cs
- DbModificationCommandTree.cs
- TextHidden.cs
- SecurityManager.cs
- TracePayload.cs
- NamedPipeChannelFactory.cs
- TextServicesLoader.cs
- GiveFeedbackEvent.cs
- ReadWriteObjectLock.cs
- CellRelation.cs
- WebHeaderCollection.cs
- KeyboardDevice.cs
- ChildTable.cs
- MissingFieldException.cs
- InternalConfigSettingsFactory.cs
- DocumentViewerHelper.cs
- SelectionPattern.cs
- AutoGeneratedFieldProperties.cs
- ParallelActivityDesigner.cs
- XmlDataDocument.cs
- ExpressionNode.cs
- ExpressionConverter.cs
- GenericIdentity.cs
- DirectoryObjectSecurity.cs
- StylusCollection.cs
- securitycriticaldataClass.cs
- PlatformCulture.cs
- XamlParser.cs
- MenuStrip.cs
- SimpleType.cs
- DirtyTextRange.cs
- updatecommandorderer.cs
- RegexFCD.cs
- DecoratedNameAttribute.cs
- ArgIterator.cs
- TransportSecurityHelpers.cs
- SiteIdentityPermission.cs
- EmptyControlCollection.cs
- DataRelationPropertyDescriptor.cs
- ProxyGenerationError.cs
- FrameworkPropertyMetadata.cs
- XmlSchemaSet.cs
- GridViewUpdatedEventArgs.cs
- VectorCollectionValueSerializer.cs
- Typeface.cs
- ObjectRef.cs
- Attributes.cs
- RegexNode.cs
- HwndSourceParameters.cs
- AuthorizationRuleCollection.cs
- odbcmetadatafactory.cs
- XmlAutoDetectWriter.cs
- DeclarativeCatalogPart.cs
- UnionCodeGroup.cs
- FaultPropagationRecord.cs
- ValidationSummaryDesigner.cs
- NetNamedPipeSecurityMode.cs
- BitmapFrameEncode.cs
- HttpClientCertificate.cs
- TransformGroup.cs
- BaseCodePageEncoding.cs
- WindowsSecurityTokenAuthenticator.cs
- WebPartExportVerb.cs
- TextDecoration.cs
- _ConnectOverlappedAsyncResult.cs
- ZipIOLocalFileBlock.cs
- Drawing.cs
- InsufficientExecutionStackException.cs
- SelectiveScrollingGrid.cs
- SignatureHelper.cs
- Annotation.cs
- ColumnMap.cs
- SystemKeyConverter.cs
- ObservableDictionary.cs
- EditorReuseAttribute.cs
- CompoundFileStreamReference.cs
- RemoteHelper.cs
- ScriptingAuthenticationServiceSection.cs
- PropertyMetadata.cs
- WebBaseEventKeyComparer.cs
- Menu.cs
- BeginEvent.cs
- HighlightComponent.cs
- Convert.cs
- Qualifier.cs
- SqlDataSourceCustomCommandEditor.cs
- GlyphRun.cs
- LoginName.cs
- WebBrowserNavigatingEventHandler.cs
- StrongNameMembershipCondition.cs
- BaseParser.cs
- ExtensionSurface.cs
- TypeRefElement.cs