예제 #1
0
        protected override int Process()
        {
            foreach (var file in Files ?? Enumerable.Empty <string> ())
            {
                var result = 0;

                try {
                    var allowProcessFile = true;

                    if (AllowedExtensions.Count > 0)
                    {
                        var ext = Path.GetExtension(file).ToLowerInvariant();
                        allowProcessFile = null != AllowedExtensions.FirstOrDefault(e => e == ext);
                    }

                    if (!File.Exists(file))
                    {
                        throw new FileNotFoundException("File not found.", file);
                    }

                    if (allowProcessFile)
                    {
                        PreProcessFile(file);
                        result = ProcessFile(file);
                        PostProcessFile(file);
                    }
                }
                catch (Exception ex) {
                    ProcessFileCatch(ex);
                    result = 1;
                }

                if (result != 0 && !ContinueOnErrors)
                {
                    return(1);
                }
            }

            return(0);
        }