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
- SchemaTypeEmitter.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- SpotLight.cs
- CodeDomLocalizationProvider.cs
- IDispatchConstantAttribute.cs
- ThousandthOfEmRealPoints.cs
- InvokeSchedule.cs
- Wrapper.cs
- SchemaObjectWriter.cs
- UpdatePanelTrigger.cs
- CustomBindingElementCollection.cs
- BasicAsyncResult.cs
- Part.cs
- EncoderFallback.cs
- URL.cs
- ApplicationException.cs
- NotImplementedException.cs
- TraceSwitch.cs
- Attribute.cs
- PageVisual.cs
- TableSectionStyle.cs
- ItemsControlAutomationPeer.cs
- Win32.cs
- FixedSOMLineCollection.cs
- PngBitmapEncoder.cs
- UnmanagedMemoryStream.cs
- TextElementEditingBehaviorAttribute.cs
- EllipseGeometry.cs
- EncryptedType.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- DataGridItemAttachedStorage.cs
- AsymmetricSignatureDeformatter.cs
- SafeThreadHandle.cs
- SplitterCancelEvent.cs
- CacheDependency.cs
- XamlContextStack.cs
- HandlerFactoryCache.cs
- IODescriptionAttribute.cs
- webeventbuffer.cs
- EventRoute.cs
- SelectionEditor.cs
- DesignerActionPropertyItem.cs
- XmlTextReaderImpl.cs
- MSAAWinEventWrap.cs
- ModelItem.cs
- PermissionToken.cs
- PersonalizationState.cs
- WmlPageAdapter.cs
- ExpressionList.cs
- RequestCachingSection.cs
- CornerRadius.cs
- MobileUserControl.cs
- FocusWithinProperty.cs
- StylusCollection.cs
- SemanticTag.cs
- FrugalList.cs
- processwaithandle.cs
- MessageQueuePermission.cs
- WebBrowsableAttribute.cs
- UriTemplate.cs
- DropDownList.cs
- AudioException.cs
- CompiledAction.cs
- UpdateExpressionVisitor.cs
- SmiEventSink.cs
- MediaCommands.cs
- SettingsBase.cs
- SendMessageChannelCache.cs
- ArraySubsetEnumerator.cs
- ADMembershipProvider.cs
- DependencyPropertyKey.cs
- DataGridViewBand.cs
- DocumentXmlWriter.cs
- RuntimeEnvironment.cs
- AccessDataSourceView.cs
- SessionParameter.cs
- ProtocolsConfigurationHandler.cs
- StreamInfo.cs
- HtmlInputText.cs
- OpCellTreeNode.cs
- XmlRootAttribute.cs
- SqlBulkCopyColumnMapping.cs
- Timer.cs
- SortDescriptionCollection.cs
- DateTimeUtil.cs
- Quad.cs
- HashHelper.cs
- HostedTransportConfigurationManager.cs
- Speller.cs
- SyndicationSerializer.cs
- Point3D.cs
- WizardStepBase.cs
- TextParagraphView.cs
- RoleManagerSection.cs
- MessageEncoderFactory.cs
- ObservableCollectionDefaultValueFactory.cs
- TypeRefElement.cs
- SoapException.cs
- ListBase.cs
- RuleAction.cs