AzurePoolCrossDbGenerator/Generators.cs
/// <summary>
/// Load an input file with a list of items, one per line
/// </summary>
/// <param name="listFileName"></param>
/// <returns></returns>
Load an input file with a list of items, one per line
Load an input file with a list of items one per line
static string LoadInputFile(string listFileName)
        {
            if (string.IsNullOrEmpty(listFileName))
            {
                Program.WriteLine();
                Program.WriteLine($"Use -l full_path or -l relative_path.", ConsoleColor.Red);
                Program.ExitApp();
            }
            string fullPath = (Path.IsPathRooted(listFileName)) ? listFileName : Path.Combine(Directory.GetCurrentDirectory(), listFileName);
            if (!System.IO.File.Exists(fullPath))
            {
                Program.WriteLine();
                Program.WriteLine($"Missing list file: {fullPath}. Use -l full_path or -l relative_path.", ConsoleColor.Red);
                Program.ExitApp();
            }
            string fileContents = null;
            try
            {
                fileContents = File.ReadAllText(fullPath);
            }
            catch (Exception ex)
            {
                Program.WriteLine();
                Program.WriteLine("Cannot read the lines file: " + ex.Message, ConsoleColor.Red);
                Program.ExitApp();
            }
            if (string.IsNullOrEmpty(fileContents))
            {
                Program.WriteLine();
                Program.WriteLine($"The -l file {fullPath} is empty.", ConsoleColor.Red);
                Program.ExitApp();
            }
            return fileContents;
        }
static string LoadInputFile ( string listFileName ) { if ( string . IsNullOrEmpty ( listFileName ) ) { Program . WriteLine ( ) ; Program . WriteLine ( $" Use -l full_path or -l relative_path. " , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } string fullPath = ( Path . IsPathRooted ( listFileName ) ) ? listFileName : Path . Combine ( Directory . GetCurrentDirectory ( ) , listFileName ) ; if ( ! System . IO . File . Exists ( fullPath ) ) { Program . WriteLine ( ) ; Program . WriteLine ( $" Missing list file:  { fullPath } . Use -l full_path or -l relative_path. " , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } string fileContents = null ; try { fileContents = File . ReadAllText ( fullPath ) ; } catch ( Exception ex ) { Program . WriteLine ( ) ; Program . WriteLine ( " " + ex . Message , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } if ( string . IsNullOrEmpty ( fileContents ) ) { Program . WriteLine ( ) ; Program . WriteLine ( $" The -l file  { fullPath }  is empty. " , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } return fileContents ; }
Load an input file with a list of items, one per line
Load an input file with a list of items one per line
// build the full path depending on the input // check if the file exists // load the file contents
None
listFileName
string
None