Exemplo n.º 1
0
        /// <summary>
        /// Prepares or initializes this group visitor for processing of its
        /// operations.
        /// </summary>
        /// <param name="context">
        /// An instance of the <see cref="BuildContext"/> specifying the
        /// build context for this visitor.
        /// </param>
        /// <remarks>
        /// This will not be initialized, if already in the initialized state.
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="context"/> is <see langword="null"/>.
        /// </exception>
        /// <seealso cref="BuildGroupVisitor.Uninitialize()"/>
        /// <seealso cref="BuildGroupVisitor.IsInitialized"/>
        public virtual void Initialize(BuildContext context)
        {
            BuildExceptions.NotNull(context, "context");

            if (_isInitialized)
            {
                BuildLogger logger = context.Logger;
                if (logger != null)
                {
                    logger.WriteLine("This visitor is already initialized.",
                                     BuildLoggerLevel.Warn);
                }

                return;
            }

            _context       = context;
            _isInitialized = true;
        }
Exemplo n.º 2
0
        public override void Initialize(BuildContext context)
        {
            base.Initialize(context);
            if (!this.IsInitialized)
            {
                return;
            }

            if (_listSteps == null || _listSteps.Count == 0)
            {
                this.IsInitialized = false;
                return;
            }

            BuildLogger logger = context.Logger;

            int stepCount = _listSteps.Count;

            for (int i = 0; i < stepCount; i++)
            {
                BuildStep buildStep = _listSteps[i];
                if (buildStep != null)
                {
                    buildStep.Initialize(context);

                    if (!buildStep.IsInitialized)
                    {
                        logger.WriteLine(
                            "An error occurred when initializing the multi-step = " + i.ToString(),
                            BuildLoggerLevel.Error);

                        this.IsInitialized = false;
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public virtual void Initialize(BuildLogger logger)
        {
            _logger = logger;

            _isInitialized = true;
        }
Exemplo n.º 4
0
        protected override bool OnExecute(BuildContext context)
        {
            BuildLogger logger = context.Logger;

            bool buildResult = true;

            if (_listSteps == null || _listSteps.Count == 0)
            {
                if (logger != null)
                {
                    logger.WriteLine("This multi-step contains no build step.",
                                     BuildLoggerLevel.Warn);
                }
                return(buildResult);
            }

            int stepCount = _listSteps.Count;

            try
            {
                for (int i = 0; i < stepCount; i++)
                {
                    BuildStep buildStep = _listSteps[i];
                    if (buildStep == null || buildStep.Enabled == false)
                    {
                        continue;
                    }
                    bool executeIt = context.StepStarts(buildStep);
                    if (executeIt == false)
                    {
                        continue;
                    }

                    if (_listMessages != null && _listMessages.Count == stepCount)
                    {
                        if (logger != null)
                        {
                            logger.WriteLine(_listMessages[i], BuildLoggerLevel.Info);
                        }
                    }

                    if (!buildStep.Execute())
                    {
                        //if (logger != null)
                        //{
                        //    logger.WriteLine(
                        //        "An error occurred in the multi-step = " + i.ToString(),
                        //        BuildLoggerLevel.Error);
                        //}
                        context.StepError(buildStep);

                        if (!buildStep.ContinueOnError)
                        {
                            buildResult = false;
                            break;
                        }
                    }

                    context.StepEnds(buildStep);

                    if (i != (stepCount - 1) && logger != null)
                    {
                        logger.WriteLine();
                    }
                }
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.WriteLine(ex, BuildLoggerLevel.Error);
                }

                buildResult = false;
            }

            return(buildResult);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="logger"></param>
        /// <seealso cref="BuildContext.IsInitialized"/>
        /// <seealso cref="BuildContext.Uninitialize()"/>
        public virtual void Initialize(BuildSettings settings, BuildLogger logger)
        {
            if (_isInitialized)
            {
                return;
            }

            _processedTopics = 0;

            BuildExceptions.NotNull(logger, "logger");
            BuildExceptions.NotNull(settings, "settings");

            Debug.Assert(_listGroups != null && _listGroups.Count != 0);
            Debug.Assert(_groupContexts != null && _groupContexts.Count != 0);

            _logger   = logger;
            _settings = settings;

            _isBuildSuccess = false;

            _sandcastleDir      = String.Empty;
            _sandcastleToolsDir = String.Empty;

            // Get the Sandcastle installed directory and tools path information....
            string sandPath = _settings.SandcastleDirectory;

            if (!String.IsNullOrEmpty(sandPath))
            {
                sandPath = Environment.ExpandEnvironmentVariables(sandPath);
                if (!Directory.Exists(sandPath))
                {
                    sandPath = Environment.ExpandEnvironmentVariables("%DXROOT%");
                }
            }
            else
            {
                sandPath = Environment.ExpandEnvironmentVariables("%DXROOT%");
            }
            if (!Directory.Exists(sandPath))
            {
                _logger.WriteLine(
                    "The sandcastle installed directory could not be found.",
                    BuildLoggerLevel.Error);

                return;
            }
            else
            {
                _sandcastleDir      = sandPath;
                _sandcastleToolsDir = Path.Combine(sandPath, "ProductionTools");
                if (!Directory.Exists(_sandcastleToolsDir))
                {
                    _sandcastleDir      = String.Empty;
                    _sandcastleToolsDir = String.Empty;

                    _logger.WriteLine(
                        "The sandcastle installed directory found, but ProductionTools sub-directory is not found.",
                        BuildLoggerLevel.Error);

                    return;
                }
                _isInitialized = this.ValidateSandcastle();
            }

            _tocContext.Initialize(this);

            if (_groupContexts != null && _groupContexts.Count != 0)
            {
                for (int i = 0; i < _groupContexts.Count; i++)
                {
                    _groupContexts[i].Initialize(this);
                }
            }

            _isInitialized = true;
        }
Exemplo n.º 6
0
 public abstract void EndDeployment(BuildLogger logger);
Exemplo n.º 7
0
 public abstract void Deployment(BuildLogger logger,
                                 BuildDirectoryPath sourcePath);
Exemplo n.º 8
0
 public abstract void BeginDeployment(BuildLogger logger);
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected virtual bool OnDefaultExecute(BuildContext context)
        {
            bool        mainResult = false;
            BuildLogger logger     = context.Logger;

            try
            {
                this.OnStartTiming();

                if (logger != null)
                {
                    if (!String.IsNullOrEmpty(_title))
                    {
                        logger.WriteLine(_title, BuildLoggerLevel.Started);
                    }
                    if (!String.IsNullOrEmpty(_message))
                    {
                        logger.WriteLine(_message, BuildLoggerLevel.Info);
                    }
                }

                mainResult = this.OnExecute(_context);

                this.OnStopTiming();

                if (mainResult)
                {
                    if (logger != null && _logTimeSpan)
                    {
                        string timeInfo = String.Empty;
                        if (this.IsMultiSteps)
                        {
                            logger.WriteLine();
                            timeInfo = String.Format("All tasks successfully completed in: {0}",
                                                     this.TimeElapsed.ToString());
                        }
                        else
                        {
                            timeInfo = String.Format("Successfully completed in: {0}",
                                                     this.TimeElapsed.ToString());
                        }
                        logger.WriteLine(timeInfo, BuildLoggerLevel.Info);
                    }
                }
                else
                {
                    if (!this.IsMultiSteps)
                    {
                        if (logger != null)
                        {
                            logger.WriteLine(this.GetType().Name + ": An error occurred in this build step.", BuildLoggerLevel.Error);
                        }
                    }
                }
            }
            finally
            {
                if (logger != null && !String.IsNullOrEmpty(_title))
                {
                    logger.WriteLine(_title, BuildLoggerLevel.Ended);
                }
            }

            return(mainResult);
        }