Ejemplo n.º 1
0
        /// <summary>
        /// Performs the additional cleaning step
        /// </summary>
        /// <param name="parameters"></param>
        public void Clean(ICleanParameters parameters)
        {
            if (parameters.KeepReferences)
            {
                var persistentReferenceBuilders = builderEnumerator.GetAllPersistentBuilders().ToList();
                var persistentBuilderPrefixes   = persistentReferenceBuilders.Select(b => b.FullName + "_").ToList();

                foreach (var directory in cacheDir.ChildDirectories)
                {
                    foreach (var prefix in persistentBuilderPrefixes)
                    {
                        if (!directory.StartsWith(prefix))
                        {
                            cacheDir.GetChildDirectory(directory).Delete();
                            break;
                        }
                        else
                        {
                            log.InfoFormat("Keeping {0} because keep-references option is active", directory);
                        }
                    }
                }

                if (!cacheDir.ChildDirectories.Any())
                {
                    cacheDir.Delete();
                }
            }
            else
            {
                cacheDir.Delete();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        public bool Run(Suite suite, string[] parameters)
        {
            var cleanParams = new CleanParameters(parameters);

            try
            {
                if (cleanParams.SoftClean)
                {
                    targetRoot.Delete(predicates.ShouldDelete);
                }
                else
                {
                    targetRoot.Delete();
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                CleanWarning(ex);
            }
            catch (IOException ex)
            {
                CleanWarning(ex);
            }

            foreach (var cleanExtension in extensions)
            {
                cleanExtension.Clean(cleanParams);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void DeleteDirectory(IFileSystemDirectory directory, ICleanParameters parameters)
        {
            var predicates = predicatesFactory();

            if (parameters.SoftClean)
                directory.Delete(predicates.ShouldDelete);
            else
                directory.Delete();
        }
Ejemplo n.º 4
0
        private void DeleteDirectory(IFileSystemDirectory directory, ICleanParameters parameters)
        {
            var predicates = predicatesFactory();

            if (parameters.SoftClean)
            {
                directory.Delete(predicates.ShouldDelete);
            }
            else
            {
                directory.Delete();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        public bool Run(Suite suite, string[] parameters)
        {
            var cleanParams = new CleanParameters(parameters);

            try
            {
                targetRoot.Delete();
            }
            catch (IOException ex)
            {
                output.Warning(String.Format("Failed to clean target root: {0}", ex.Message),
                               new [] {
                    "A command prompt may have its current directory set there",
                    "Maybe the process is running"
                });
            }

            foreach (var cleanExtension in extensions)
            {
                cleanExtension.Clean(cleanParams);
            }

            return(true);
        }