blob: 492358dbcefb51aa99b3d7140c0724ec13e51e04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
//------------------------------------------------------------------------------
// <copyright file="CacheOutputQuery.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <owner current="true" primary="true">[....]</owner>
//------------------------------------------------------------------------------
namespace MS.Internal.Xml.XPath {
using System;
using System.Xml;
using System.Xml.XPath;
using System.Diagnostics;
using System.Xml.Xsl;
using System.Collections.Generic;
internal abstract class CacheOutputQuery : Query {
internal Query input;
// int count; -- we reusing it here
protected List<XPathNavigator> outputBuffer;
public CacheOutputQuery(Query input) {
this.input = input;
this.outputBuffer = new List<XPathNavigator>();
this.count = 0;
}
protected CacheOutputQuery(CacheOutputQuery other) : base(other) {
this.input = Clone(other.input);
this.outputBuffer = new List<XPathNavigator>(other.outputBuffer);
this.count = other.count;
}
public override void Reset() {
this.count = 0;
}
public override void SetXsltContext(XsltContext context){
input.SetXsltContext(context);
}
public override object Evaluate(XPathNodeIterator context) {
outputBuffer.Clear();
count = 0;
return input.Evaluate(context);// This is trick. IDQuery needs this value. Otherwise we would return this.
// All subclasses should and would anyway override thismethod and return this.
}
public override XPathNavigator Advance() {
Debug.Assert(0 <= count && count <= outputBuffer.Count);
if (count < outputBuffer.Count) {
return outputBuffer[count++];
}
return null;
}
public override XPathNavigator Current {
get {
Debug.Assert(0 <= count && count <= outputBuffer.Count);
if (count == 0) {
return null;
}
return outputBuffer[count - 1];
}
}
public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } }
public override int CurrentPosition { get { return count; } }
public override int Count { get { return outputBuffer.Count; } }
public override QueryProps Properties { get { return QueryProps.Merge | QueryProps.Cached | QueryProps.Position | QueryProps.Count; } }
public override void PrintQuery(XmlWriter w) {
w.WriteStartElement(this.GetType().Name);
input.PrintQuery(w);
w.WriteEndElement();
}
}
}
|