Ejemplo n.º 1
0
        /// <summary>
        /// Matching last string in include expression against all files and select the first match. 
        /// This is incredibly basic and not necessarily correct. The path is ignored and there could be multiple files
        /// with the same name. 
        /// </summary>
        public bool TryResolveInclude(XmlNode node, out File path)
        {
            Preconditions.NotNull(node, "node");
            Preconditions.IsTrue(node.Name == AstConstants.Node + ":" + AstConstants.Nodes.Expr_Include, "Given node was not an include node. It was " + node.Name, "node");

            string includeString = "";

            node.IterateAllNodes(xmlNode =>
                                 {
                                     if (xmlNode.LocalName != AstConstants.Nodes.Scalar_String)
                                         return false;
                                     includeString = xmlNode.GetSubNode(AstConstants.Subnode + ":" + AstConstants.Subnodes.Value).InnerText;
                                     return true;
                                 });

            string fileName = Path.GetFileName(includeString);

            return TryGetFile(fileName, out path);
        }