@@ -80,7 +80,13 @@ public IEnumerable<object[]> ReadNodes()
8080 return null ;
8181 }
8282
83- if ( ! System . IO . File . Exists ( this . ConfigObject . FileName ) )
83+ var fileName = System . IO . Path . IsPathRooted ( this . ConfigObject . FileName )
84+ ? this . ConfigObject . FileName
85+ : System . IO . Path . Combine (
86+ this . Engine . GetInitVar ( nameof ( InitVar . DefaultDir ) ) ,
87+ this . ConfigObject . FileName ) ;
88+
89+ if ( ! System . IO . File . Exists ( fileName ) )
8490 {
8591 this . Message ( $ "File { this . ConfigObject . FileName } could not be read.", MessageStatus . STATUS_Error ) ;
8692 return null ;
@@ -90,7 +96,7 @@ public IEnumerable<object[]> ReadNodes()
9096
9197 try
9298 {
93- document . Load ( this . ConfigObject . FileName ) ;
99+ document . Load ( fileName ) ;
94100 }
95101 catch ( XmlException ex )
96102 {
@@ -105,6 +111,8 @@ public IEnumerable<object[]> ReadNodes()
105111 /// Read All The Xml Nodes From A Node
106112 /// Recursive scan from input node
107113 /// </summary>
114+ /// <param name="node">Xml node to scan</param>
115+ /// <param name="path">Current path to node</param>
108116 /// <returns>List of nodes</returns>
109117 public IEnumerable < object [ ] > ReadNodes ( XmlNode node , string path = "" )
110118 {
@@ -115,14 +123,14 @@ public IEnumerable<object[]> ReadNodes(XmlNode node, string path = "")
115123
116124 path = path + "/" + ( node is XmlAttribute ? "@" : "" ) + node . Name ;
117125
118- var nodes = node . ChildNodes . Cast < XmlNode > ( ) ;
126+ var nodes = node . ChildNodes . Cast < XmlNode > ( ) . ToArray ( ) ;
119127 var txtNodes = nodes . Where ( x => x . Name == "#text" ) . ToArray ( ) ;
120128
121- var txt = txtNodes . Length == 0 ? node . InnerText : null ;
129+ var txt = nodes . Length == 0 ? node . InnerText : null ;
122130 if ( txtNodes . Length == 1 )
123131 {
124132 txt = txtNodes [ 0 ] . InnerText ;
125- nodes = nodes . Where ( n => n . Name != "#text" ) ;
133+ nodes = nodes . Where ( n => n . Name != "#text" ) . ToArray ( ) ;
126134 }
127135
128136 IEnumerable < object [ ] > result = new [ ] { new object [ ] { path , txt , node . InnerXml } } ;
0 commit comments