예제 #1
0
        public BigSqlRunner(BigSqlRunnerConfig config)
        {
            if (null == config)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Config = config;
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
 public static string ToJson(BigSqlRunnerConfig config) => JsonConvert.SerializeObject(config, Formatting.Indented);