Все собирается вместе, но у меня есть одна проблема, решение которой я еще не нашел. Учитывая основной код консоли:
Код: Выделить всё
class Program
{
static void Main(string[] args)
{
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
serviceProvider.GetService().Generate();
}
private static void ConfigureServices(IServiceCollection serviceCollection)
{
var configurationRoot = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appSettings.json", false)
.Build();
serviceCollection.AddOptions();
serviceCollection.Configure(configurationRoot.GetSection("Configuration"));
// add services
serviceCollection.AddScoped()
.AddScoped();
}
}
Код: Выделить всё
public class CodeGen
{
private readonly IDataRepo _dataRepo;
private readonly AppSettings _appSettings;
public CodeGen(IDataRepo dataRepo, AppSettings appSettings)
{
_dataRepo = dataRepo;
_appSettings = appSettings;
}
public void Generate()
{
Console.WriteLine("Generates code... ");
CodeGenWordRules.Init(_appSettings.OutputFolder, _dataRepo);
}
}
Код: Выделить всё
public DataRepo(IConfiguration configuration, ICodeGenManager codeGenManager)
Подробнее здесь: https://stackoverflow.com/questions/697 ... et-console
Мобильная версия