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
- InvalidComObjectException.cs
- ArraySortHelper.cs
- Encoder.cs
- KnownBoxes.cs
- CapabilitiesUse.cs
- FilteredAttributeCollection.cs
- UpdatePanelTriggerCollection.cs
- NTAccount.cs
- SecurityManager.cs
- PeerToPeerException.cs
- SecurityElement.cs
- InvalidCastException.cs
- CroppedBitmap.cs
- HtmlElementCollection.cs
- FrameworkContextData.cs
- IntellisenseTextBox.designer.cs
- ProfilePropertySettings.cs
- TemplateControlBuildProvider.cs
- ConfigurationStrings.cs
- WebPartMenu.cs
- VisualTarget.cs
- Internal.cs
- SecurityKeyIdentifier.cs
- KeyboardEventArgs.cs
- ColumnMap.cs
- XmlRootAttribute.cs
- XPathMultyIterator.cs
- AsyncOperationContext.cs
- ChangePassword.cs
- CodeTypeReferenceExpression.cs
- MatrixTransform.cs
- EmbeddedObject.cs
- XmlAttributeOverrides.cs
- VisualStateGroup.cs
- CancellationTokenSource.cs
- DescendantBaseQuery.cs
- EventProviderWriter.cs
- SoapSchemaImporter.cs
- HttpCachePolicyWrapper.cs
- XmlSchemaAttribute.cs
- DataGridViewColumnConverter.cs
- RectKeyFrameCollection.cs
- SafeThreadHandle.cs
- ArrangedElementCollection.cs
- RenderDataDrawingContext.cs
- DoubleCollection.cs
- PropertyItem.cs
- BookmarkManager.cs
- TrackingServices.cs
- Context.cs
- CodeDomDecompiler.cs
- SafeProcessHandle.cs
- complextypematerializer.cs
- RecommendedAsConfigurableAttribute.cs
- DllNotFoundException.cs
- KerberosReceiverSecurityToken.cs
- SequentialWorkflowRootDesigner.cs
- Misc.cs
- XmlSchemaAnnotated.cs
- XpsManager.cs
- SecondaryIndexList.cs
- WindowsGraphicsWrapper.cs
- ResXBuildProvider.cs
- BaseParser.cs
- SqlException.cs
- DocumentPageViewAutomationPeer.cs
- CompositeControlDesigner.cs
- PropertyIDSet.cs
- StorageAssociationTypeMapping.cs
- HideDisabledControlAdapter.cs
- WebContext.cs
- ProviderIncompatibleException.cs
- ByteAnimationBase.cs
- TabItemAutomationPeer.cs
- PermissionRequestEvidence.cs
- LicenseManager.cs
- CharAnimationUsingKeyFrames.cs
- DiscriminatorMap.cs
- HostSecurityManager.cs
- StrongNamePublicKeyBlob.cs
- XmlNamespaceMappingCollection.cs
- XmlCharCheckingWriter.cs
- CheckBoxList.cs
- TraceContextRecord.cs
- TextDecorationCollection.cs
- CultureSpecificCharacterBufferRange.cs
- TdsEnums.cs
- RawMouseInputReport.cs
- ListViewUpdateEventArgs.cs
- AsymmetricSignatureFormatter.cs
- BulletChrome.cs
- BamlBinaryWriter.cs
- EntityConnection.cs
- CloudCollection.cs
- RealProxy.cs
- GroupLabel.cs
- FileChangesMonitor.cs
- MiniParameterInfo.cs
- DesignTimeData.cs
- AuthStoreRoleProvider.cs