Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / MatchSingleFxEngineOpcode.cs / 1 / MatchSingleFxEngineOpcode.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System; using System.ServiceModel.Channels; using System.Collections.Generic; using System.Xml; using System.Xml.XPath; using System.Diagnostics; ////// Opcode that evaluates a single xpath query using the framework engine /// internal class MatchSingleFxEngineOpcode : QueryResultOpcode { XPathExpression xpath; XPathMessageFilter filter; internal MatchSingleFxEngineOpcode() : base(OpcodeID.MatchSingleFx) { this.flags |= OpcodeFlags.FxMatch; } internal XPathMessageFilter Filter { #if NO get { return this.filter; } #endif set { this.filter = value; } } internal XPathExpression XPath { #if NO get { return this.xpath; } #endif set { this.xpath = value; } } internal override void CollectXPathFilters(ICollectionfilters) { filters.Add(filter); } internal override bool Equals(Opcode op) { return false; } internal override Opcode Eval(ProcessingContext context) { DiagnosticUtility.DebugAssert(null != this.xpath, ""); SeekableXPathNavigator targetNav = context.Processor.ContextNode; #if FILTER_SELECT if (context.Processor.IsMatch) { #endif bool result = this.Match(targetNav); context.Processor.Result = result; if (result && null != this.filter && null != context.Processor.ResultSet) { context.Processor.ResultSet.Add(this.filter); } #if FILTER_SELECT } else if (context.Processor.IsSelect) { context.Processor.SelectResults = this.Select(targetNav); } #endif return this.next; } internal object Evaluate(XPathNavigator nav) { SeekableMessageNavigator messageNav = nav as SeekableMessageNavigator; if (null != messageNav) { // If operating on messages, we would have avoided atomizing unless we were using the Framework // This ensures that atomization has taken place messageNav.Atomize(); } object evalResult; if (XPathResultType.NodeSet == xpath.ReturnType) { evalResult = nav.Select(xpath); } else { evalResult = nav.Evaluate(xpath); } return evalResult; } internal bool Match(XPathNavigator nav) { bool retVal; object evalResult = this.Evaluate(nav); switch (xpath.ReturnType) { default: retVal = false; break; case XPathResultType.Any: retVal = (null != evalResult); break; case XPathResultType.Boolean: retVal = (bool)evalResult; break; case XPathResultType.NodeSet: XPathNodeIterator iterator = (XPathNodeIterator) evalResult; retVal = (null != iterator && iterator.Count > 0); break; case XPathResultType.Number: retVal = (((double)evalResult) != 0.0); break; case XPathResultType.String: string strVal = (string)evalResult; retVal = (null != strVal && strVal.Length > 0); // see XPath 1.0 break; } return retVal; } internal string Select(XPathNavigator nav) { string retVal = string.Empty; object evalResult = this.Evaluate(nav); switch (xpath.ReturnType) { default: break; case XPathResultType.Boolean: retVal = QueryValueModel.String((bool)evalResult); break; case XPathResultType.NodeSet: XPathNodeIterator iterator = (XPathNodeIterator) evalResult; if (iterator.MoveNext()) { retVal = iterator.Current.Value; } break; case XPathResultType.Number: retVal = QueryValueModel.String((double) evalResult); break; case XPathResultType.String: retVal = (string)evalResult; break; } return retVal; } } } // 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
- ModelVisual3D.cs
- EntityFrameworkVersions.cs
- ExtensionQuery.cs
- TraceHandler.cs
- LazyInitializer.cs
- ProtocolsConfigurationHandler.cs
- SByte.cs
- TargetParameterCountException.cs
- BaseValidator.cs
- Transform.cs
- Baml2006Reader.cs
- SourceFileInfo.cs
- MultilineStringConverter.cs
- IsolatedStorageFilePermission.cs
- ListBox.cs
- WorkflowTransactionOptions.cs
- TcpHostedTransportConfiguration.cs
- SerializationFieldInfo.cs
- BaseResourcesBuildProvider.cs
- Brushes.cs
- CompiledIdentityConstraint.cs
- ScriptingAuthenticationServiceSection.cs
- Misc.cs
- SymLanguageVendor.cs
- SecurityTokenParameters.cs
- BufferedOutputStream.cs
- CancellationState.cs
- InstalledVoice.cs
- ToolBarButton.cs
- WindowsEditBoxRange.cs
- MatrixTransform3D.cs
- ViewBase.cs
- ToolboxItemWrapper.cs
- WeakEventTable.cs
- ContextStaticAttribute.cs
- SamlAction.cs
- SafeCryptHandles.cs
- _LocalDataStore.cs
- StorageRoot.cs
- InstanceOwnerQueryResult.cs
- InstanceKeyCompleteException.cs
- FontFamily.cs
- SchemaMapping.cs
- _DisconnectOverlappedAsyncResult.cs
- wpf-etw.cs
- ObjectDataSourceStatusEventArgs.cs
- CultureMapper.cs
- DbConnectionPoolGroupProviderInfo.cs
- TextParagraphProperties.cs
- OracleDateTime.cs
- PathFigure.cs
- XslAstAnalyzer.cs
- RMPermissions.cs
- GraphicsState.cs
- XmlQualifiedNameTest.cs
- SortExpressionBuilder.cs
- SqlGatherConsumedAliases.cs
- ClientUtils.cs
- ListViewGroupItemCollection.cs
- NegotiationTokenAuthenticator.cs
- HierarchicalDataBoundControl.cs
- FutureFactory.cs
- TakeOrSkipQueryOperator.cs
- ScrollBar.cs
- SessionIDManager.cs
- UxThemeWrapper.cs
- CodeDefaultValueExpression.cs
- Matrix3D.cs
- DataRelationPropertyDescriptor.cs
- KeyTimeConverter.cs
- BasePropertyDescriptor.cs
- RemoteWebConfigurationHost.cs
- GridViewColumnCollection.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- MatrixTransform.cs
- XmlArrayItemAttributes.cs
- TreeNodeMouseHoverEvent.cs
- PartialCachingAttribute.cs
- RSATokenProvider.cs
- BindingGroup.cs
- UnmanagedMarshal.cs
- DataGridViewCellStyle.cs
- RegisteredHiddenField.cs
- BaseDataListDesigner.cs
- SqlTriggerAttribute.cs
- DbProviderFactory.cs
- DriveInfo.cs
- basecomparevalidator.cs
- Model3DCollection.cs
- DbProviderFactories.cs
- SectionInformation.cs
- DBCommand.cs
- DataGridViewLinkColumn.cs
- ThemeableAttribute.cs
- GenericUriParser.cs
- DropDownButton.cs
- HttpHandlersSection.cs
- BatchStream.cs
- CustomExpressionEventArgs.cs
- WpfKnownMember.cs