public BigSqlRunner(BigSqlRunnerConfig config) { if (null == config) { throw new ArgumentNullException(nameof(config)); } Config = config; }
public static void ToFile(BigSqlRunnerConfig config, string configFilePath) { var configJson = ToJson(config); var parentDir = Path.GetDirectoryName(configFilePath); if (false == Directory.Exists(parentDir)) { Directory.CreateDirectory(parentDir); } File.WriteAllText(configFilePath, configJson); }
public static BigSqlRunner FromDefaultConfig() { var configFilePath = GetDefaultConfigFilePath(); if (false == File.Exists(configFilePath)) { return(null); } var config = BigSqlRunnerConfig.FromFile(configFilePath); var bigSqlRunner = new BigSqlRunner(config); return(bigSqlRunner); }
public bool LoadConfig(string configFilePath = null) { if (null == configFilePath) { configFilePath = GetDefaultConfigFilePath(); } else if (string.IsNullOrWhiteSpace(configFilePath)) { throw new ArgumentException($"{nameof(configFilePath)} cannot be blank", nameof(configFilePath)); } if (false == File.Exists(configFilePath)) { return(false); } Config = BigSqlRunnerConfig.FromFile(configFilePath); return(true); }
public static string ToJson(BigSqlRunnerConfig config) => JsonConvert.SerializeObject(config, Formatting.Indented);