public InputStruct GetInput(string[] args) { InputStruct res = new InputStruct(); res.Action = GetAction(args); res.InputFileInfo = new FileInfo(args[1]); res.OutPutFileInfo = new FileInfo(args[2]); return(res); }
static void Main(string[] args) { #if DEBUG args = new string[3]; args[0] = CommonApplicationConstants.COMPRESS; args[1] = @"C:\test\test21.mkv"; args[2] = @"C:\test\test21.mkv"; #endif string errMsg; var collection = new ServiceCollection(); collection.AddScoped <IInputService, InputService>(); var serviceProvider = collection.BuildServiceProvider(); var inputServ = serviceProvider.GetService <IInputService>(); if (inputServ.ValidateArgs(args, out errMsg)) { InputStruct inputStruct = inputServ.GetInput(args); switch (inputStruct.Action) { case Constant.ActionType.Compress: action = new CompressAction(inputStruct.InputFileInfo.FullName, inputStruct.OutPutFileInfo.FullName); break; case Constant.ActionType.Decompress: action = new DecompressAction(inputStruct.InputFileInfo.FullName, inputStruct.OutPutFileInfo.FullName); break; } action.Start(); } else { Console.WriteLine(errMsg); } }