private void MainForm_Load(object sender, EventArgs e) { _secureFile = new SecureFile(_key); _secureFile.ChunkUpdate += SecureFile_ChunkUpdate; _secureFile.ProcessCompleted += SecureFile_ProcessCompleted; if (!SecureDelete.IsPossible()) { MessageBox.Show("Secure Deletion of Files not possible. SDelete wasn't found in this Directory. Please download it and save it inside the DataEncrypter directory.", "No Secure Deletion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
static void Main(string[] args) { var interpreter = new CommandInterpreter(new CommandInterpreterOptions { KeepCommandIdentifier = true }); var commandData = interpreter.InterpretTokenBase(args); var pipeline = new ApplicationPipline(); var isInInteractiveMode = false; pipeline .Add("--T", "-v", (_, next) => { var s = Input.GetPassword("Type Password: "******"[{s}]"); return(next()); }) .Add("--sDelete", "-sdel", (filePath, next) => { SecureDelete.Delete(filePath, 2).GetAwaiter().GetResult(); return(next()); }) .Add(new AddFileCommand()) .Add(new ExecuteBatchCommand()) .Add("--help", "-h", (_, next) => { Console.WriteLine("You are in help. We will not run anything else in the pipeline."); return(Task.CompletedTask); }) .Add("--ViewFile", "-v", (_, next) => { foreach (var item in Global.InputFiles) { Console.WriteLine(item); } return(next()); }) .Add("--ClearFile", "-cf", (_, next) => { Global.InputFiles.Clear(); Console.WriteLine("All files cleared"); return(next()); }) .Add("--encrypt", "-e", (_, next) => { Global.WorkType = WorkType.Encrypt; Console.WriteLine("Execution is not set for encryption."); return(next()); }) .Add("--decrypt", "-d", (_, next) => { Global.WorkType = WorkType.Decrypt; Console.WriteLine("Execution is not set for decryption."); return(next()); }) .Add("--UserId", "-u", (userId, next) => { Global.UserId = userId; return(next()); }) .Add("--SetWorkLoad", "-w", (workLoadType, next) => { if (int.TryParse(workLoadType, out var workLoadInt)) { Global.WorkLoad = (WorkLoad)workLoadInt; } return(next()); }) .Add(new DelegateCommand("--print", "-p", (message, next) => { Console.WriteLine(message); return(next()); })) .Add("--it", (_, next) => { isInInteractiveMode = true; return(next()); }); pipeline.Execute(commandData).GetAwaiter().GetResult(); string input = null; while (isInInteractiveMode && input != "q") { Console.Write("$ "); input = Console.ReadLine(); if (!string.IsNullOrEmpty(input)) { // args = $"--{input}".Split(' ', StringSplitOptions.RemoveEmptyEntries); args = CommandInterpreter.GetArgsFromString($"--{input}"); commandData = interpreter.InterpretTokenBase(args); pipeline.Execute(commandData).GetAwaiter().GetResult(); } } }