예제 #1
0
        private bool RunDirectAssembler(BuildContext context)
        {
            int         processedTopics = 0;
            bool        isSuccessful    = false;
            BuildLogger logger          = context.Logger;

            AppDomain assemblerDomain = null;

            try
            {
                assemblerDomain = AppDomain.CreateDomain(
                    "Sandcastle.BuildAssemblerDomain");

                SandcastleAssemblerTool assemblerProxy =
                    (SandcastleAssemblerTool)assemblerDomain.CreateInstanceAndUnwrap(
                        typeof(SandcastleAssemblerTool).Assembly.FullName,
                        typeof(SandcastleAssemblerTool).FullName);

                assemblerProxy.ManifestFile      = _manifestFile;
                assemblerProxy.ConfigurationFile = _configurationFile;

                isSuccessful = assemblerProxy.Run(context);

                processedTopics = assemblerProxy.TopicsProcessed;
            }
            catch (Exception ex)
            {
                logger.WriteLine(ex);
            }
            finally
            {
                if (assemblerDomain != null)
                {
                    AppDomain.Unload(assemblerDomain);
                    assemblerDomain = null;
                }
            }

            context.AddProcessedTopics(processedTopics);

            return(isSuccessful);
        }
예제 #2
0
        protected override bool OnExecute(BuildContext context)
        {
            BuildLogger logger = context.Logger;

            if (logger != null)
            {
                _verbosity = logger.Verbosity;
            }

            if (_group == null)
            {
                throw new BuildException(
                          "The build group for this step is required.");
            }

            if (_group.GroupType == BuildGroupType.Reference)
            {
                if (!CreateConfiguration((ReferenceGroup)_group))
                {
                    return(false);
                }
            }
            else if (_group.GroupType == BuildGroupType.Conceptual)
            {
                if (!CreateConfiguration((ConceptualGroup)_group))
                {
                    return(false);
                }
            }

            bool buildResult = false;

            if (context.IsDirectSandcastle)
            {
                buildResult = this.RunDirectAssembler(context);
            }
            else
            {
                buildResult = base.OnExecute(context);

                if (buildResult && !String.IsNullOrEmpty(_lastMessage) &&
                    _lastMessage.StartsWith("Processed", StringComparison.OrdinalIgnoreCase))
                {
                    if (_logger != null && _lastLevel == BuildLoggerLevel.Info &&
                        _verbosity == BuildLoggerVerbosity.Normal &&
                        _verbosity != BuildLoggerVerbosity.Quiet)
                    {
                        _logger.WriteLine(_lastMessage, BuildLoggerLevel.Info);
                    }

                    int startIndex = _lastMessage.IndexOf("topics");

                    if (startIndex > 0)
                    {
                        int processedTopics;
                        if (Int32.TryParse(_lastMessage.Substring(9,
                                                                  startIndex - 9).Trim(), out processedTopics))
                        {
                            context.AddProcessedTopics(processedTopics);
                        }
                    }
                }
            }

            return(buildResult);
        }