コード例 #1
0
        /// <summary>
        /// This gets all possible content files from the project and attempts
        /// to match them to the topics in the collection by ID.
        /// </summary>
        public void MatchProjectFilesToTopics()
        {
            SandcastleProject project = fileItem.ProjectElement.Project;
            FileItem          topicItem;
            TopicFile         topicFile;

            string ext, none = BuildAction.None.ToString(),
                   content = BuildAction.Content.ToString();

            foreach (ProjectItem item in project.MSBuildProject.AllEvaluatedItems)
            {
                if (item.ItemType == none || item.ItemType == content)
                {
                    ext = Path.GetExtension(item.EvaluatedInclude).ToLowerInvariant();

                    if (ext == ".aml" || ext == ".htm" || ext == ".html" || ext == ".topic")
                    {
                        topicItem = new FileItem(new ProjectElement(project, item));
                        topicFile = new TopicFile(topicItem);

                        if (topicFile.Id != null)
                        {
                            this.SetTopic(topicFile);
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Set the topic file in any entry that has a matching ID
        /// </summary>
        /// <param name="topicFile">The topic file</param>
        /// <remarks>The IDs should be unique across all entries but, if a duplicate exists, this will help find
        /// it as we'll get a more descriptive error later in the build.</remarks>
        private void SetTopic(TopicFile topicFile)
        {
            foreach (Topic t in this)
            {
                if (t.Id == topicFile.Id)
                {
                    t.TopicFile = topicFile;
                }

                if (t.Subtopics.Count != 0)
                {
                    t.Subtopics.SetTopic(topicFile);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// This gets all possible content files from the project and attempts to match them to the topics in the
        /// collection by ID.
        /// </summary>
        public void MatchProjectFilesToTopics()
        {
            TopicFile topicFile;
            string    ext;

            foreach (var contentFile in contentLayoutFile.ContentFileProvider.ContentFiles(BuildAction.None))
            {
                ext = Path.GetExtension(contentFile.Filename).ToLowerInvariant();

                if (ext == ".aml")
                {
                    topicFile = new TopicFile(contentFile);

                    if (topicFile.Id != null)
                    {
                        this.SetTopic(topicFile);
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// When the build finishes, load the topic if it was built
        /// successfully or view the log if the build failed.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        /// <remarks>We have to wait for the thread to finish before we can
        /// view the log file so we use a timer event to wait for it.</remarks>
        private void timer_Tick(object sender, EventArgs e)
        {
            TopicFile topicFile;
            string path = null;
            string[] files;

            if(buildThread != null && !buildThread.IsAlive)
            {
                timer.Stop();

                // If successful, preview the built topic
                if(lastBuildStep == BuildStep.Completed)
                {
                    // If it's a MAML topic or an HTML file with an ID, use
                    // the ID for the name.
                    topicFile = new TopicFile(fileItem);

                    if(!String.IsNullOrEmpty(topicFile.Id))
                        path = String.Concat(buildProcess.WorkingFolder,
                            @"Output\Website\html\", topicFile.Id, ".htm");
                    else
                    {
                        // If not, try to find it by name
                        files = Directory.GetFiles(buildProcess.WorkingFolder +
                            @"Output\Website\", Path.GetFileNameWithoutExtension(
                            fileItem.Name) + ".htm?", SearchOption.AllDirectories);

                        if(files.Length != 0)
                            path = files[0];
                        else
                            path = fileItem.FullPath;
                    }

                    if(File.Exists(path))
                        wbPreview.Navigate(path);
                    else
                        wbPreview.DocumentText = "Unable to locate built " +
                            "topic file: " + path + "<br/><br/>Does the " +
                            "project contain a content layout file with a " +
                            "<b>BuildAction</b> of <b>ContentLayout</b>?";
                }
                else
                    wbPreview.DocumentText = OutputWindow.TransformLogFile(
                        buildProcess.LogFilename, Settings.Default.FilterBuildLog);

                pbWait.Visible = lblLoading.Visible = false;
                buildThread = null;
                buildProcess = null;
            }
        }