コード例 #1
0
        /// <summary>
        /// This cleans up any resources being used.
        /// </summary>
        /// <param name="disposing">
        /// This is <see langword="true"/> if managed resources should be
        /// disposed; otherwise, <see langword="false"/>.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (_tocAdapter != null)
            {
                _tocAdapter.Dispose();
                _tocAdapter = null;
            }
            if (_metadataAdapter != null)
            {
                _metadataAdapter.Dispose();
                _metadataAdapter = null;
            }
            if (_manifestAdapters != null)
            {
                _manifestAdapters.Dispose();
                _manifestAdapters = null;
            }

            base.Dispose(disposing);
        }
コード例 #2
0
        /// <summary>
        /// Applies the processing operations defined by this visitor to the
        /// specified conceptual group.
        /// </summary>
        /// <param name="group">
        /// The <see cref="ConceptualGroup">conceptual group</see> to which
        /// the processing operations defined by this visitor will be applied.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="group"/> is <see langword="null"/>.
        /// </exception>
        protected override void OnVisit(ConceptualGroup group)
        {
            BuildExceptions.NotNull(group, "group");

            if (!this.IsInitialized)
            {
                throw new BuildException(
                          "ConceptualProjectVisitor: The conceptual table of contents generator is not initialized.");
            }

            BuildContext context = this.Context;
            BuildLogger  logger  = context.Logger;

            BuildGroupContext groupContext = context.GroupContexts[group.Id];

            if (groupContext == null)
            {
                throw new BuildException(
                          "The group context is not provided, and it is required by the build system.");
            }

            if (logger != null)
            {
                logger.WriteLine("Begin - Creating Conceptual Resource Settings.",
                                 BuildLoggerLevel.Info);
            }

            _tocAdapter       = new ConceptualTocAdapter();
            _metadataAdapter  = new ConceptualMetadataAdapter();
            _manifestAdapters = new ConceptualManifestAdapter();

            try
            {
                _tocAdapter.Initialize(group, context);
                _metadataAdapter.Initialize(group, context);
                _manifestAdapters.Initialize(group, context);

                string workingDir = context.WorkingDirectory;

                _ddueXmlDir  = Path.Combine(workingDir, groupContext["$DdueXmlDir"]);
                _ddueCompDir = Path.Combine(workingDir, groupContext["$DdueXmlCompDir"]);
                _ddueHtmlDir = Path.Combine(workingDir, groupContext["$DdueHtmlDir"]);

                if (!Directory.Exists(_ddueXmlDir))
                {
                    Directory.CreateDirectory(_ddueXmlDir);
                }
                if (!Directory.Exists(_ddueCompDir))
                {
                    Directory.CreateDirectory(_ddueCompDir);
                }
                if (!Directory.Exists(_ddueHtmlDir))
                {
                    Directory.CreateDirectory(_ddueHtmlDir);
                }

                ConceptualContent content = group.Content;
                int itemCount             = content.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    this.WriteTopic(content[i]);
                }

                IList <ConceptualRelatedTopic> relatedTopics = content.RelatedTopics;
                if (relatedTopics != null && relatedTopics.Count != 0)
                {
                    itemCount = relatedTopics.Count;
                    for (int i = 0; i < itemCount; i++)
                    {
                        ConceptualRelatedTopic topicItem = relatedTopics[i];
                        if (topicItem == null || topicItem.IsEmpty)
                        {
                            continue;
                        }

                        this.WriteTopic(topicItem);
                    }
                }
            }
            finally
            {
                _tocAdapter.Uninitialize();
                _metadataAdapter.Uninitialize();
                _manifestAdapters.Uninitialize();
            }

            if (logger != null)
            {
                logger.WriteLine("Completed - Creating Conceptual Resource Settings.",
                                 BuildLoggerLevel.Info);
            }
        }