System.Xml.Xsl.Runtime.XmlQueryRuntime.FindIndex C# (CSharp) Method

FindIndex() public method

If an index having the specified Id has already been created over the "context" document, then return it in "index" and return true. Otherwise, create a new, empty index and return false.
public FindIndex ( XPathNavigator context, int indexId, XmlILIndex &index ) : bool
context System.Xml.XPath.XPathNavigator
indexId int
index XmlILIndex
return bool
        public bool FindIndex(XPathNavigator context, int indexId, out XmlILIndex index) {
            XPathNavigator navRoot;
            ArrayList docIndexes;
            Debug.Assert(context != null);

            // Get root of document
            navRoot = context.Clone();
            navRoot.MoveToRoot();

            // Search pre-existing indexes in order to determine whether the specified index has already been created
            if (this.indexes != null && indexId < this.indexes.Length) {
                docIndexes = (ArrayList) this.indexes[indexId];
                if (docIndexes != null) {
                    // Search for an index defined over the specified document
                    for (int i = 0; i < docIndexes.Count; i += 2) {
                        // If we find a matching document, then return the index saved in the next slot
                        if (((XPathNavigator) docIndexes[i]).IsSamePosition(navRoot)) {
                            index = (XmlILIndex) docIndexes[i + 1];
                            return true;
                        }
                    }
                }
            }

            // Return a new, empty index
            index = new XmlILIndex();
            return false;
        }