public void Validate() { if (!File.Exists(InputFilePath)) { throw new ArgumentException("Input file does not exist"); } if (OutputFilePath.EndsWith('/') || OutputFilePath.EndsWith('\\')) { throw new ArgumentException("Output file must be a file path not directory."); } if (ColumnsToMask.Count() == 0) { throw new ArgumentException("Column cannot be empty."); } }
private static void ProcessArguments(string[] args) { InputFilePath = args[0]; string pathWithoutFile = Path.GetDirectoryName(InputFilePath); string fileWithoutPath = Path.GetFileName(InputFilePath); bool hasThreeSizes = false; if (string.IsNullOrEmpty(pathWithoutFile)) { pathWithoutFile = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); } else if (!Directory.Exists(pathWithoutFile)) { Directory.CreateDirectory(pathWithoutFile); } InputFilePath = pathWithoutFile + "//" + fileWithoutPath; OutputFilePath = args.Last(); if (!Directory.Exists(OutputFilePath) && !File.Exists(OutputFilePath)) { OutputFilePath = pathWithoutFile + "\\" + OutputFilePath; if (!File.Exists(OutputFilePath)) { File.Create(OutputFilePath); } } if (!OutputFilePath.EndsWith(".csv")) { OutputFilePath += ".csv"; } ContainerWidth = Int32.Parse(args[1]); ContainerHeight = Int32.Parse(args[2]); int tmpDepth; if (Int32.TryParse(args[3], out tmpDepth)) { ContainerDepth = tmpDepth; hasThreeSizes = true; } Properties = new AlgorithmProperties(); if (hasThreeSizes) { if (args.Count() > 5 && arguments.Contains(args[4])) { RecognizePair(args[4], args[5]); } if (args.Count() > 7 && arguments.Contains(args[6])) { RecognizePair(args[6], args[7]); } if (args.Count() > 9 && arguments.Contains(args[8])) { RecognizePair(args[8], args[9]); } if (args.Count() > 11 && arguments.Contains(args[10])) { RecognizePair(args[10], args[11]); } } else { if (args.Count() > 4 && arguments.Contains(args[3])) { RecognizePair(args[3], args[4]); } if (args.Count() > 6 && arguments.Contains(args[5])) { RecognizePair(args[5], args[6]); } if (args.Count() > 8 && arguments.Contains(args[7])) { RecognizePair(args[7], args[8]); } if (args.Count() > 10 && arguments.Contains(args[9])) { RecognizePair(args[9], args[10]); } } }