Пример #1
0
        protected virtual IEnumerable <UoeDatabaseConnection> GetDatabaseConnections(bool addDatabasesInCurrentDirectory, bool throwWhenNoDatabaseFound)
        {
            var nbYield = 0;

            foreach (var connection in DatabaseConnections.ToNonNullEnumerable().Where(c => !string.IsNullOrEmpty(c)))
            {
                foreach (var databaseConnection in UoeDatabaseConnection.GetConnectionStrings(connection))
                {
                    nbYield++;
                    yield return(databaseConnection);
                }
            }
            var ope = GetOperator();

            foreach (var path in DatabasePaths.ToNonNullEnumerable().Where(d => !string.IsNullOrEmpty(d)))
            {
                nbYield++;
                var loc = new UoeDatabaseLocation(path);
                loc.ThrowIfNotExist();
                yield return(ope.GetDatabaseConnection(loc));
            }
            if (!addDatabasesInCurrentDirectory && throwWhenNoDatabaseFound)
            {
                throw new CommandException($"You must specify a database connection string using the option {OptionDatabaseConnectionShortName.PrettyQuote()} or a database path by using the option {OptionDatabaseFileShortName.PrettyQuote()}.");
            }
            if (nbYield > 0 || !addDatabasesInCurrentDirectory)
            {
                yield break;
            }
            foreach (var databaseLocation in GetDatabaseLocationsFromCd(throwWhenNoDatabaseFound))
            {
                databaseLocation.ThrowIfNotExist();
                yield return(ope.GetDatabaseConnection(databaseLocation));
            }
        }
Пример #2
0
        protected virtual IEnumerable <UoeDatabaseLocation> GetDatabaseLocations(bool addDatabasesInCurrentDirectory, bool throwWhenNoDatabaseFound)
        {
            var nbYield = 0;

            foreach (var path in DatabasePaths.ToNonNullEnumerable().Where(d => !string.IsNullOrEmpty(d)))
            {
                nbYield++;
                yield return(new UoeDatabaseLocation(path));
            }
            if (!addDatabasesInCurrentDirectory && throwWhenNoDatabaseFound)
            {
                throw new CommandException($"You must specify a database path by using the option {OptionDatabaseFileShortName.PrettyQuote()}.");
            }
            if (nbYield > 0 || !addDatabasesInCurrentDirectory)
            {
                yield break;
            }
            foreach (var databaseLocation in GetDatabaseLocationsFromCd(throwWhenNoDatabaseFound))
            {
                yield return(databaseLocation);
            }
        }
 public string DatabaseTranslateUrl(string language) => DatabasePaths.DatabaseTranslateFilePath(SourcesUrl, language);