protected virtual void ProcessConfigurationItems(XmlDocument configDoc) { XPathNavigator navigator = configDoc.CreateNavigator(); XPathNodeIterator iterator = navigator.Select("//SandcastleItem"); if (iterator == null || iterator.Count == 0) { return; } int nodeCount = iterator.Count; XPathNavigator[] nodeNavigators = new XPathNavigator[iterator.Count]; for (int i = 0; i < nodeNavigators.Length; i++) { iterator.MoveNext(); nodeNavigators[i] = iterator.Current.Clone(); } string configKeyword = null; ConfiguratorItem configItem = null; for (int i = 0; i < nodeCount; i++) { XPathNavigator nodeNavigator = nodeNavigators[i]; configKeyword = nodeNavigator.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(configKeyword)) { continue; } configItem = _configContent[configKeyword]; if (configItem != null) { configItem.Execute(nodeNavigator); } } }
public void Configure(ReferenceGroup group, string sourceFile, string destFile) { BuildExceptions.NotNull(group, "group"); BuildExceptions.PathMustExist(sourceFile, "sourceFile"); BuildExceptions.NotNullNotEmpty(destFile, "destFile"); if (this.IsInitialized == false) { throw new BuildException( "The reference filter configurator is not initialized."); } _group = group; _sourceFile = sourceFile; _destFile = destFile; string destDir = Path.GetDirectoryName(destFile); if (Directory.Exists(destDir) == false) { Directory.CreateDirectory(destDir); } if (this.IsInitialized == false || String.IsNullOrEmpty(_sourceFile) || String.IsNullOrEmpty(_destFile)) { return; } XmlDocument document = new XmlDocument(); document.Load(_sourceFile); XPathNavigator navigator = document.CreateNavigator(); XPathNodeIterator iterator = navigator.Select("//SandcastleItem"); int nodeCount = iterator.Count; XPathNavigator[] nodeNavigators = new XPathNavigator[iterator.Count]; for (int i = 0; i < nodeNavigators.Length; i++) { iterator.MoveNext(); nodeNavigators[i] = iterator.Current.Clone(); } string configKeyword = null; ConfiguratorItem configItem = null; for (int i = 0; i < nodeCount; i++) { XPathNavigator nodeNavigator = nodeNavigators[i]; configKeyword = nodeNavigator.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(configKeyword)) { continue; } configItem = _configContent[configKeyword]; if (configItem != null) { configItem.Execute(nodeNavigator); } } this.ApplyContents(document); document.Save(_destFile); }
public virtual void Configure(string sourceFile, string destFile) { BuildExceptions.PathMustExist(sourceFile, "sourceFile"); BuildExceptions.NotNullNotEmpty(destFile, "destFile"); if (this.IsInitialized == false) { throw new BuildException("The configurator is not initialized."); } _sourceFile = sourceFile; _destFile = destFile; string destDir = Path.GetDirectoryName(destFile); if (Directory.Exists(destDir) == false) { Directory.CreateDirectory(destDir); } XmlDocument configDoc = new XmlDocument(); configDoc.Load(_sourceFile); if (_configContent != null && _configContent.IsEmpty == false) { XPathNavigator docNavigator = configDoc.CreateNavigator(); XPathNodeIterator iterator = docNavigator.Select("//SandcastleItem"); if (iterator != null && iterator.Count != 0) { int nodeCount = iterator.Count; XPathNavigator[] navigators = new XPathNavigator[iterator.Count]; for (int i = 0; i < navigators.Length; i++) { iterator.MoveNext(); navigators[i] = iterator.Current.Clone(); } string configKeyword = null; ConfiguratorItem configItem = null; for (int i = 0; i < nodeCount; i++) { XPathNavigator navigator = navigators[i]; configKeyword = navigator.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(configKeyword)) { continue; } configItem = _configContent[configKeyword]; if (configItem != null) { configItem.Execute(navigator); } } } } this.ApplyContents(configDoc); configDoc.Save(_destFile); }