Beispiel #1
0
        private static (string, string) GetSourceOutputFileNames(FileOptions options)
        {
            var inputFileName = options.InputFileName;

            if (!File.Exists(inputFileName))
            {
                throw new ArgumentException($"Incorrect filename: ({options.InputFileName}) (file doesn't exist)");
            }
            var imgFormat = options.OutputFileNameExtension.ToLower();

            if (!SupportedImageFormats.Contains(imgFormat))
            {
                throw new ArgumentException($"Incorrect image format: ({imgFormat}) (google helps)");
            }

            var outputFileName = $"{options.OutputFileName}.{imgFormat}";

            return(inputFileName, outputFileName);
        }
Beispiel #2
0
 private static void ResolveBoringList(FileOptions options, ContainerBuilder builder)
 {
     if (options.BoringListFileName is null)
     {
         return;
     }
     if (!File.Exists(options.BoringListFileName))
     {
         throw new ArgumentException($"There is no such file with boring rules. {options.BoringListFileName}");
     }
     if (Path.GetExtension(options.BoringListFileName) != ".txt")
     {
         throw new ArgumentException($"File with boring rule should be plain text: {options.BoringListFileName}");
     }
     builder
     .RegisterType <BoringListRule>()
     .WithParameter("boringList", File.ReadLines(options.BoringListFileName))
     .As <IPreprocessingRule>();
 }