AzurePoolCrossDbGenerator/Configs.cs
/// <summary>
/// Load the config file or notify of problems and exit.
/// </summary>
/// <param name="configFileName">Can be rooted or relative to the current directory.</param>
/// <returns></returns>
Load the config file or notify of problems and exit.
Load the config file or notify of problems and exit .
static string LoadConfigFile(string configFileName)
        {
            if (string.IsNullOrEmpty(configFileName))
            {
                Program.WriteLine();
                Program.WriteLine($"Use -c full_path or -c relative_path.", ConsoleColor.Red);
                Program.ExitApp();
            }
            if (!configFileName.Contains("\\") && !configFileName.Contains("/")) configFileName = Path.Combine(Program.FileNames.ConfigFolder, configFileName);
            string fullPath = (Path.IsPathRooted(configFileName)) ? configFileName : Path.Combine(Directory.GetCurrentDirectory(), configFileName);
            if (!System.IO.File.Exists(fullPath))
            {
                Program.WriteLine();
                Program.WriteLine($"Missing config file: {fullPath}. Use -c full_path or -c relative_path or -c file_name_in_scripts_subfolder.", ConsoleColor.Red);
                Program.ExitApp();
            }
            string configJson = null;
            try
            {
                configJson = File.ReadAllText(fullPath);
            }
            catch (Exception ex)
            {
                Program.WriteLine();
                Program.WriteLine("Cannot read the config file: " + ex.Message, ConsoleColor.Red);
                Program.ExitApp();
            }
            return configJson;
        }
static string LoadConfigFile ( string configFileName ) { if ( string . IsNullOrEmpty ( configFileName ) ) { Program . WriteLine ( ) ; Program . WriteLine ( $" Use -c full_path or -c relative_path. " , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } if ( ! configFileName . Contains ( " \\ " ) && ! configFileName . Contains ( " " ) ) configFileName = Path . Combine ( Program . FileNames . ConfigFolder , configFileName ) ; string fullPath = ( Path . IsPathRooted ( configFileName ) ) ? configFileName : Path . Combine ( Directory . GetCurrentDirectory ( ) , configFileName ) ; if ( ! System . IO . File . Exists ( fullPath ) ) { Program . WriteLine ( ) ; Program . WriteLine ( $" Missing config file:  { fullPath } . Use -c full_path or -c relative_path or -c file_name_in_scripts_subfolder. " , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } string configJson = null ; try { configJson = File . ReadAllText ( fullPath ) ; } catch ( Exception ex ) { Program . WriteLine ( ) ; Program . WriteLine ( " " + ex . Message , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } return configJson ; }
Load the config file or notify of problems and exit.
Load the config file or notify of problems and exit .
// build the full path depending on the input // check if the file exists // load the config file
None
configFileName
string
Can be rooted or relative to the current directory.
Can be rooted or relative to the current directory .