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
- PropertyEmitterBase.cs
- ValuePattern.cs
- Mutex.cs
- MgmtConfigurationRecord.cs
- HttpListenerTimeoutManager.cs
- AssemblyBuilder.cs
- ComponentCommands.cs
- FloaterBaseParaClient.cs
- MultiBindingExpression.cs
- HttpHeaderCollection.cs
- MULTI_QI.cs
- NamespaceCollection.cs
- ToolStripComboBox.cs
- dbdatarecord.cs
- HandleCollector.cs
- behaviorssection.cs
- ListViewDataItem.cs
- SchemaMerger.cs
- PathFigureCollectionConverter.cs
- XmlSchemaComplexContent.cs
- X509WindowsSecurityToken.cs
- DescendantOverDescendantQuery.cs
- FixedHighlight.cs
- TraceContextEventArgs.cs
- RegexCapture.cs
- AggregateNode.cs
- DocumentPageHost.cs
- ReadOnlyPropertyMetadata.cs
- FontStyles.cs
- TimeoutException.cs
- CqlErrorHelper.cs
- TypeReference.cs
- PersianCalendar.cs
- ComponentGlyph.cs
- PersonalizationDictionary.cs
- Compiler.cs
- TagElement.cs
- InputMethod.cs
- SkinBuilder.cs
- Overlapped.cs
- XsdDateTime.cs
- FocusWithinProperty.cs
- Msec.cs
- TextTreeTextElementNode.cs
- PriorityQueue.cs
- Simplifier.cs
- SqlConnectionManager.cs
- TimeSpanValidator.cs
- PageStatePersister.cs
- DoubleAverageAggregationOperator.cs
- wgx_commands.cs
- XmlSchemaAnnotation.cs
- TimeSpanOrInfiniteConverter.cs
- ClaimComparer.cs
- UserPreferenceChangedEventArgs.cs
- CharacterMetricsDictionary.cs
- SpellerStatusTable.cs
- TypeUtil.cs
- MatrixTransform.cs
- CustomPeerResolverService.cs
- MainMenu.cs
- ScrollChrome.cs
- PointKeyFrameCollection.cs
- FlowLayout.cs
- SynchronizationContext.cs
- SplitterCancelEvent.cs
- CSharpCodeProvider.cs
- NameScopePropertyAttribute.cs
- IpcServerChannel.cs
- EncoderParameters.cs
- DateTimeOffsetStorage.cs
- TextParagraph.cs
- UrlMappingCollection.cs
- SocketInformation.cs
- ComponentEditorForm.cs
- RawUIStateInputReport.cs
- FieldToken.cs
- EntityDataSourceWizardForm.cs
- Accessible.cs
- ProviderConnectionPoint.cs
- XmlNullResolver.cs
- XmlValidatingReaderImpl.cs
- SymbolDocumentInfo.cs
- ImageAnimator.cs
- ScriptMethodAttribute.cs
- IItemContainerGenerator.cs
- HideDisabledControlAdapter.cs
- SafeRegistryHandle.cs
- ProxyWebPartManager.cs
- TextDecorationLocationValidation.cs
- GridViewCommandEventArgs.cs
- StorageComplexPropertyMapping.cs
- RegexCompiler.cs
- DocComment.cs
- RegisteredHiddenField.cs
- DoWorkEventArgs.cs
- HtmlTableRow.cs
- IdentifierCollection.cs
- QilInvokeLateBound.cs
- ScrollBar.cs