1 //------------------------------------------------------------------------------
2 // <copyright file="CacheOutputQuery.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace MS.Internal.Xml.XPath {
11 using System.Xml.XPath;
12 using System.Diagnostics;
14 using System.Collections.Generic;
16 internal abstract class CacheOutputQuery : Query {
18 // int count; -- we reusing it here
19 protected List<XPathNavigator> outputBuffer;
21 public CacheOutputQuery(Query input) {
23 this.outputBuffer = new List<XPathNavigator>();
26 protected CacheOutputQuery(CacheOutputQuery other) : base(other) {
27 this.input = Clone(other.input);
28 this.outputBuffer = new List<XPathNavigator>(other.outputBuffer);
29 this.count = other.count;
32 public override void Reset() {
36 public override void SetXsltContext(XsltContext context){
37 input.SetXsltContext(context);
40 public override object Evaluate(XPathNodeIterator context) {
43 return input.Evaluate(context);// This is trick. IDQuery needs this value. Otherwise we would return this.
44 // All subclasses should and would anyway override thismethod and return this.
47 public override XPathNavigator Advance() {
48 Debug.Assert(0 <= count && count <= outputBuffer.Count);
49 if (count < outputBuffer.Count) {
50 return outputBuffer[count++];
55 public override XPathNavigator Current {
57 Debug.Assert(0 <= count && count <= outputBuffer.Count);
61 return outputBuffer[count - 1];
65 public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } }
66 public override int CurrentPosition { get { return count; } }
67 public override int Count { get { return outputBuffer.Count; } }
68 public override QueryProps Properties { get { return QueryProps.Merge | QueryProps.Cached | QueryProps.Position | QueryProps.Count; } }
70 public override void PrintQuery(XmlWriter w) {
71 w.WriteStartElement(this.GetType().Name);