/// <summary> /// Creates a folder hierarchy: /// ProjectDir /// \ Areas /// \ AreaName /// \ Controllers /// \ Data /// \ Models /// \ Views /// </summary> private void EnsureFolderLayout(AreaGeneratorCommandLine model) { var areaBasePath = Path.Combine(_appInfo.ApplicationBasePath, "Areas"); if (!Directory.Exists(areaBasePath)) { Directory.CreateDirectory(areaBasePath); } var areaPath = Path.Combine(areaBasePath, model.Name); if (!Directory.Exists(areaPath)) { Directory.CreateDirectory(areaPath); } foreach (var areaFolder in AreaFolders) { var path = Path.Combine(areaPath, areaFolder); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } }
public async Task GenerateCode(AreaGeneratorCommandLine model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } EnsureFolderLayout(model); var readmeGenerator = ActivatorUtilities.CreateInstance <ReadMeGenerator>(_serviceProvider); try { await readmeGenerator.GenerateReadmeForArea(); } catch (Exception ex) { _logger.LogMessage(string.Format(MessageStrings.ReadmeGenerationFailed, ex.Message)); throw ex.Unwrap(_logger); } }