Beispiel #1
0
        private static string ExpandNow(XmlNode section, string baseDirectory, ChoNestedDictionary <string, XmlNode> includeFileList, ChoNestedDictionary <string, XmlNode> includeSubFileList,
                                        XmlElement includeElement, string includeFileName, XmlNamespaceManager xmlnsManager)
        {
            if (String.IsNullOrEmpty(includeFileName))
            {
                RemoveIncludeNode(includeElement);
                return(includeFileName);
            }
            else if (!Path.IsPathRooted(includeFileName) && !String.IsNullOrEmpty(baseDirectory))
            {
                includeFileName = Path.Combine(baseDirectory, includeFileName);
            }

            //if (!File.Exists(includeFileName))
            //    RemoveIncludeNode(section, includeElement);

            if (IsCircularFileExists(includeFileList, includeFileName))
            {
                throw new ChoXmlDocumentException(String.Format("Circular reference encountered on the {0} file.", baseDirectory));
            }

            XmlNode[] newNodes = InsertNodes(includeElement, includeFileName, ExtractNodes(includeElement, includeFileName));
            if (newNodes != null)
            {
                foreach (XmlNode newNode in newNodes)
                {
                    if (!includeSubFileList.ContainsKey(includeFileName))
                    {
                        includeSubFileList.Add(includeFileName, newNode);
                    }
                    baseDirectory = Path.GetDirectoryName(includeFileName);
                    ExpandIncludes(newNode, baseDirectory, includeSubFileList, xmlnsManager);
                }
            }
            //includeSubFileList.Add(includeFileName, includeElement);
            return(includeFileName);
        }
Beispiel #2
0
 private static bool IsCircularFileExists(ChoNestedDictionary <string, XmlNode> parentFileList, string xmlFilePath)
 {
     return(parentFileList.ContainsKey(xmlFilePath));            //.Exists(delegate(string item) { return String.Compare(item, xmlFilePath, true) == 0; });
 }