Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / QueryResultOp.cs / 1 / QueryResultOp.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System; using System.ServiceModel.Channels; using System.Xml; using System.Xml.XPath; using System.Diagnostics; using System.Collections.Generic; ////// Base class for opcodes that produce the query's final result /// internal abstract class QueryResultOpcode : Opcode { internal QueryResultOpcode(OpcodeID id) : base(id) { this.flags |= OpcodeFlags.Result; } } internal class MatchQueryResultOpcode : QueryResultOpcode { internal MatchQueryResultOpcode() : this(OpcodeID.MatchQueryResult) { } protected MatchQueryResultOpcode(OpcodeID id) : base(id) { this.flags |= OpcodeFlags.Result; } internal override Opcode Eval(ProcessingContext context) { context.Processor.Result = this.IsSuccess(context); context.PopFrame(); return this.next; } protected bool IsSuccess(ProcessingContext context) { StackFrame topFrame = context.TopArg; #if FILTER_SELECT if (context.Processor.IsMatch) { #endif if (1 == topFrame.Count) { return context.Values[topFrame.basePtr].ToBoolean(); } else { context.Processor.Result = false; for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i) { if (context.Values[i].ToBoolean()) { return true; } } } #if FILTER_SELECT } else if (context.Processor.IsSelect) { string results = string.Empty; if (topFrame.Count > 0) { DiagnosticUtility.DebugAssert(topFrame.Count == 1, ""); results = context.Values[topFrame.basePtr].ToString(); } context.Processor.SelectResults = results; } #endif return false; } } #if NO internal class MatchFilterResultOpcode : MatchQueryResultOpcode { MessageFilter resultFilter; internal MatchFilterResultOpcode(MessageFilter resultFilter) : base(OpcodeID.MatchFilterResult) { DiagnosticUtility.DebugAssert(null != resultFilter, ""); this.resultFilter = resultFilter; } internal MessageFilter Result { get { return this.resultFilter; } } internal override void Add(Opcode op) { MatchFilterResultOpcode filterResult = op as MatchFilterResultOpcode; if (null == filterResult) { base.Add(op); return; } MatchMultipleFilterResultOpcode multipleResults = new MatchMultipleFilterResultOpcode(); DiagnosticUtility.DebugAssert(null != this.prev, ""); this.prev.Replace(this, multipleResults); if (null != this.next) { this.next.Prev = multipleResults; this.next = null; } multipleResults.Add(filterResult); multipleResults.Add(this); } // One MatchFilterResultOpcode result code is always treated equivalent to another internal override bool Equals(Opcode op) { if (base.Equals(op)) { MatchFilterResultOpcode resultOp = op as MatchFilterResultOpcode; return object.ReferenceEquals(resultOp.resultFilter, this.resultFilter); } return false; } internal override Opcode Eval(ProcessingContext context) { if (this.IsSuccess(context)) { context.Processor.ResultSet.Add(this.resultFilter); } return null; } internal override void Remove() { if (null == this.resultFilter) { base.Remove(); } } internal void Remove(MessageFilter resultFilter) { if (resultFilter == this.resultFilter) { this.resultFilter = null; DiagnosticUtility.DebugAssert(null != this.next, ""); base.Remove(); } } } #endif internal class MatchMultipleFilterResultOpcode : MatchQueryResultOpcode { internal QueryBufferresults; internal MatchMultipleFilterResultOpcode(XPathMessageFilter filter) : this() { this.results = new QueryBuffer (1); this.results.Add(filter); } internal MatchMultipleFilterResultOpcode() : base(OpcodeID.MatchMultipleFilterResult) { this.results = new QueryBuffer (0); } internal override void Add(Opcode op) { #if NO MatchFilterResultOpcode resultOp = op as MatchFilterResultOpcode; if (null != resultOp) { this.results.Add(resultOp.Result); return; } #endif MatchMultipleFilterResultOpcode results = op as MatchMultipleFilterResultOpcode; if (null != results) { this.results.Add(ref results.results); this.results.TrimToCount(); return; } base.Add(op); } internal override void CollectXPathFilters(ICollection filters) { for(int i = 0; i < this.results.Count; ++i) { filters.Add(this.results[i]); } } internal override bool Equals(Opcode op) { if (base.Equals (op)) { return object.ReferenceEquals(this, op); } return false; } internal override Opcode Eval(ProcessingContext context) { if (this.IsSuccess(context)) { ICollection matches = context.Processor.ResultSet; for (int i = 0, count = this.results.Count; i < count; ++i) { matches.Add(this.results[i]); } } context.PopFrame(); return this.next; } internal override void Remove() { if (0 == this.results.Count) { base.Remove(); } } internal void Remove(XPathMessageFilter resultFilter) { DiagnosticUtility.DebugAssert(null != resultFilter, ""); this.results.Remove(resultFilter); this.Remove(); } internal override void Trim() { this.results.TrimToCount(); } } } // 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
- TdsParserSessionPool.cs
- StringPropertyBuilder.cs
- BaseParser.cs
- DataSourceHelper.cs
- CacheMemory.cs
- ellipse.cs
- ScopelessEnumAttribute.cs
- ObjectMemberMapping.cs
- coordinatorscratchpad.cs
- AspNetHostingPermission.cs
- BitmapDownload.cs
- SvcMapFileLoader.cs
- FullTextLine.cs
- AttributeCollection.cs
- TextParentUndoUnit.cs
- X509ChainPolicy.cs
- ClientApiGenerator.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- XmlSchemaNotation.cs
- XPathNavigatorKeyComparer.cs
- MimeMapping.cs
- ProtocolImporter.cs
- SerializerDescriptor.cs
- GridViewUpdateEventArgs.cs
- coordinatorscratchpad.cs
- ConfigurationManagerHelperFactory.cs
- XPathDocumentNavigator.cs
- SafeMarshalContext.cs
- PixelShader.cs
- SqlDataSourceView.cs
- ConfigurationStrings.cs
- PrintPreviewControl.cs
- DPTypeDescriptorContext.cs
- ExitEventArgs.cs
- DataGridViewControlCollection.cs
- TextSegment.cs
- MethodRental.cs
- ProcessHostFactoryHelper.cs
- OutOfProcStateClientManager.cs
- HttpServerVarsCollection.cs
- OracleMonthSpan.cs
- PreviewPrintController.cs
- UIntPtr.cs
- JsonFormatReaderGenerator.cs
- XhtmlBasicCommandAdapter.cs
- XmlSchemaValidationException.cs
- EncryptedPackageFilter.cs
- SqlReferenceCollection.cs
- Item.cs
- DataPagerFieldItem.cs
- MsdtcClusterUtils.cs
- TextRunProperties.cs
- DefaultPrintController.cs
- DoubleConverter.cs
- XmlSerializerNamespaces.cs
- EnumValAlphaComparer.cs
- DefinitionUpdate.cs
- StorageModelBuildProvider.cs
- QueueException.cs
- PanelContainerDesigner.cs
- ControlPaint.cs
- Part.cs
- ConfigurationFileMap.cs
- CssTextWriter.cs
- RemotingAttributes.cs
- WebPartConnectionCollection.cs
- RightsManagementPermission.cs
- SimpleMailWebEventProvider.cs
- FilterableAttribute.cs
- XDRSchema.cs
- UserNamePasswordServiceCredential.cs
- BaseTemplateCodeDomTreeGenerator.cs
- StaticResourceExtension.cs
- EditorZoneBase.cs
- XmlSchemaInferenceException.cs
- IndicShape.cs
- Utility.cs
- ContainerControl.cs
- ExceptionHandler.cs
- ConstructorArgumentAttribute.cs
- CSharpCodeProvider.cs
- HtmlEmptyTagControlBuilder.cs
- SoapConverter.cs
- SelectedPathEditor.cs
- WebRequestModuleElement.cs
- PauseStoryboard.cs
- GeometryCollection.cs
- WebBrowserContainer.cs
- PublisherMembershipCondition.cs
- FormsAuthenticationCredentials.cs
- ActiveXHelper.cs
- SqlDelegatedTransaction.cs
- MarshalByRefObject.cs
- Activity.cs
- LinearKeyFrames.cs
- _HelperAsyncResults.cs
- Canvas.cs
- AddInIpcChannel.cs
- DynamicScriptObject.cs
- FontFamilyConverter.cs