public BigSqlRunner(BigSqlRunnerConfig config) { if (null == config) { throw new ArgumentNullException(nameof(config)); } Config = config; LogPool = new LogPool(config.MaxLogItemCount, config.CompactLog); }
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 bool LoadConfig(string configFilePath) { if (string.IsNullOrWhiteSpace(configFilePath)) { throw new ArgumentException($"{nameof(configFilePath)} cannot be null or whitespace", nameof(configFilePath)); } else if (false == NetPatch.FileExists(configFilePath)) { return(false); } Config = BigSqlRunnerConfig.FromFile(configFilePath); return(true); }
public static BigSqlRunner FromConfig(string configFilePath) { if (string.IsNullOrWhiteSpace(configFilePath)) { throw new ArgumentException($"{nameof(configFilePath)} cannot be null or whitespace", nameof(configFilePath)); } else if (false == NetPatch.FileExists(configFilePath)) { return(null); } var config = BigSqlRunnerConfig.FromFile(configFilePath); var bigSqlRunner = new BigSqlRunner(config); return(bigSqlRunner); }
public static string ToJson(BigSqlRunnerConfig config) => JsonConvert.SerializeObject(config, Formatting.Indented);