OnCreateComponentConfiguration(string name, bool isPlugin)
        {
            BuildExceptions.NotNullNotEmpty(name, "name");

            switch (name.ToLower())
            {
            case "sandcastle.conceptual.conceptualpretransconfiguration":
                return(new ConceptualPreTransConfiguration());

            case "sandcastle.conceptual.conceptualintellisenseconfiguration":
                return(new ConceptualIntelliSenseConfiguration());

            case "sandcastle.conceptual.conceptualcloneconfiguration":
                return(new ConceptualCloneConfiguration());

            case "sandcastle.conceptual.conceptualposttransconfiguration":
                return(new ConceptualPostTransConfiguration());

            case "sandcastle.conceptual.conceptualcodeconfiguration":
                return(new ConceptualCodeConfiguration());

            case "sandcastle.conceptual.conceptualmathconfiguration":
                return(new ConceptualMathConfiguration());

            case "sandcastle.conceptual.conceptualmediaconfiguration":
                return(new ConceptualMediaConfiguration());

            case "sandcastle.conceptual.conceptuallinkconfiguration":
                return(new ConceptualLinkConfiguration());

            case "sandcastle.conceptual.conceptualreferencelinkconfiguration":
                return(new ConceptualReferenceLinkConfiguration());

            case "sandcastle.conceptual.conceptualsharedconfiguration":
                return(new ConceptualSharedConfiguration());
            }

            return(base.OnCreateComponentConfiguration(name, isPlugin));
        }
Exemplo n.º 2
0
        public void Export(string contentFile)
        {
            BuildExceptions.NotNullNotEmpty(contentFile, "contentFile");

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent             = true;
            settings.IndentChars        = new string(' ', 4);
            settings.Encoding           = Encoding.UTF8;
            settings.OmitXmlDeclaration = false;

            XmlWriter writer = null;

            try
            {
                writer = XmlWriter.Create(contentFile, settings);

                writer.WriteStartDocument();

                this.ExportXml(writer);

                writer.WriteEndDocument();

                // The file content is now same as the memory, so it can be
                // considered loaded...
                _isLoaded = true;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                    writer = null;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a relative path from one file or folder to another.
        /// </summary>
        /// <param name="basePath">
        /// Contains the directory that defines the start of the relative path.
        /// </param>
        /// <param name="absolutePath">
        /// Contains the path that defines the endpoint of the relative path.
        /// </param>
        /// <returns>
        /// The relative path from the start directory to the end path.
        /// </returns>
        public static string GetRelativePath(string basePath, string absolutePath)
        {
            if (basePath != null)
            {
                basePath = basePath.Trim();
            }
            if (absolutePath != null)
            {
                absolutePath = absolutePath.Trim();
            }

            BuildExceptions.NotNullNotEmpty(basePath, "basePath");

            BuildExceptions.NotNullNotEmpty(absolutePath, "absolutePath");

            string result = String.Empty;

            if (String.IsNullOrEmpty(basePath) || String.IsNullOrEmpty(absolutePath))
            {
                return(result);
            }

            basePath = Path.GetFullPath(
                Environment.ExpandEnvironmentVariables(basePath));

            StringBuilder path           = new StringBuilder(MAX_PATH);
            uint          fromAttributes = DirectoryUtils.IsDirectory(basePath) ? FILE_ATTRIBUTE_DIRECTORY : 0;
            uint          toAttributes   = DirectoryUtils.IsDirectory(absolutePath) ? FILE_ATTRIBUTE_DIRECTORY : 0;

            if (PathRelativePathTo(path, basePath, fromAttributes, absolutePath, toAttributes))
            {
                result = path.ToString();
            }

            return(result);
        }
        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);
        }
Exemplo n.º 5
0
        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);
        }