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
- DataListItemEventArgs.cs
- CurrentTimeZone.cs
- EmptyStringExpandableObjectConverter.cs
- ModuleElement.cs
- DbMetaDataCollectionNames.cs
- Translator.cs
- DatagridviewDisplayedBandsData.cs
- CodeSnippetExpression.cs
- SerialPinChanges.cs
- Byte.cs
- DropShadowBitmapEffect.cs
- DropSource.cs
- ExecutionContext.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- PointF.cs
- PropertyCondition.cs
- ChangesetResponse.cs
- Timer.cs
- _ListenerRequestStream.cs
- OraclePermissionAttribute.cs
- Tokenizer.cs
- assertwrapper.cs
- ProxyGenerationError.cs
- SqlCacheDependency.cs
- ProxyAttribute.cs
- BulletChrome.cs
- TextHidden.cs
- InputElement.cs
- AssemblyInfo.cs
- XmlKeywords.cs
- SymbolTable.cs
- StandardBindingReliableSessionElement.cs
- ZipPackagePart.cs
- TimeSpanValidatorAttribute.cs
- VBIdentifierNameEditor.cs
- EntryPointNotFoundException.cs
- FloaterBaseParaClient.cs
- SerializationFieldInfo.cs
- DoubleAnimationUsingPath.cs
- FormParameter.cs
- TimeSpanStorage.cs
- FieldNameLookup.cs
- PingReply.cs
- SetStateDesigner.cs
- ContextMenuAutomationPeer.cs
- StringUtil.cs
- InvalidPropValue.cs
- ButtonStandardAdapter.cs
- LayoutTable.cs
- ConditionalDesigner.cs
- StringFormat.cs
- WindowsToolbarAsMenu.cs
- Point3DKeyFrameCollection.cs
- TimeSpanValidatorAttribute.cs
- SlipBehavior.cs
- xamlnodes.cs
- WebResponse.cs
- PublisherIdentityPermission.cs
- VirtualDirectoryMapping.cs
- PropertyPushdownHelper.cs
- SessionPageStatePersister.cs
- DataControlField.cs
- FrameSecurityDescriptor.cs
- XmlAnyAttributeAttribute.cs
- AllMembershipCondition.cs
- StyleCollection.cs
- ListDictionaryInternal.cs
- InternalResources.cs
- DSASignatureDeformatter.cs
- DispatcherExceptionEventArgs.cs
- UnionCqlBlock.cs
- DataBoundControl.cs
- ArrangedElement.cs
- DataGridViewSortCompareEventArgs.cs
- BindUriHelper.cs
- DataGridColumnHeadersPresenter.cs
- ClosableStream.cs
- StorageComplexTypeMapping.cs
- RelatedView.cs
- WsdlWriter.cs
- DataListItem.cs
- Internal.cs
- CanonicalFontFamilyReference.cs
- ScrollableControl.cs
- SqlResolver.cs
- ConfigXmlText.cs
- EventLogPermissionEntryCollection.cs
- ConstraintEnumerator.cs
- ViewDesigner.cs
- Fonts.cs
- WCFModelStrings.Designer.cs
- StateItem.cs
- DLinqColumnProvider.cs
- OracleParameterCollection.cs
- HwndHost.cs
- FormViewUpdatedEventArgs.cs
- KeyProperty.cs
- XmlSchemaObjectTable.cs
- GridEntryCollection.cs
- SoapSchemaImporter.cs