private IOperationOptions GetTypeOptions(string type, CommandOptions options) { switch (type) { case "install": var installOperationOptions = new InstallOperationOptions(); installOperationOptions.Inputfilename = "tools.gti"; if (!string.IsNullOrWhiteSpace(options.InputFilename)) { installOperationOptions.Inputfilename = options.InputFilename; } return(installOperationOptions); case "save": var saveOperationOptions = new SaveOperationOptions(); saveOperationOptions.Outputfilename = "tools.gti"; if (!string.IsNullOrWhiteSpace(options.OutputFilename)) { saveOperationOptions.Outputfilename = options.OutputFilename; } saveOperationOptions.OutputType = "csv"; if (!string.IsNullOrWhiteSpace(options.OutputType)) { saveOperationOptions.OutputType = options.OutputType; } return(saveOperationOptions); default: throw new ArgumentOutOfRangeException($"Invalid operation requested {options.Command}, valid operations are [save,install]"); } }
public void SetOperationOptions(IOperationOptions options) { var op = options as InstallOperationOptions; if (op == null) { throw new ArgumentException(nameof(options)); } else { _options = op; } }