/// <summary>
        /// Validate the options
        /// </summary>
        /// <returns></returns>
        public bool ValidateArgs(out string errorMessage)
        {
            if (string.IsNullOrWhiteSpace(DirectoryPath))
            {
                errorMessage = "Use /I to specify the starting directory";
                return(false);
            }

            if (string.IsNullOrWhiteSpace(InputFileNameFilter))
            {
                errorMessage = "Use /F to specify the file name (or names) to process";
                return(false);
            }

            if (string.IsNullOrWhiteSpace(SearchReplaceFilePath))
            {
                errorMessage = "Use /T to specify the file with text to find and replacement text";
                return(false);
            }

            InputFileNames.Clear();
            foreach (var filename in InputFileNameFilter.Split(';'))
            {
                InputFileNames.Add(filename);
            }

            errorMessage = string.Empty;

            return(true);
        }
示例#2
0
        private DateTime GetLastInputModifyDate()
        {
            var filesLastModifyDate = InputFileNames.Select(x =>
            {
                string fileName = Path.Combine(InputWorkingPath, x);
                if (File.Exists(fileName))
                {
                    return(File.GetLastWriteTimeUtc(fileName));
                }
                else
                {
                    Log.Warning($"File {fileName} was not found.");
                    return(DateTime.MinValue);
                }
            }).Max();
            var assemblyModifyDate = GetAssemblyModifyDate();

            if (assemblyModifyDate.Ticks > filesLastModifyDate.Ticks)
            {
                return(assemblyModifyDate);
            }
            return(filesLastModifyDate);
        }