public Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var entityNameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Entity); var namePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Name); var nameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Name); var nameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name); var template = _templateLocator.Get("GenerateEditOverlayComponentCommand"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ entityNameSnakeCase }}", entityNameSnakeCase }, { "{{ namePascalCase }}", namePascalCase }, { "{{ nameCamelCase }}", nameCamelCase }, { "{{ nameSnakeCase }}", nameSnakeCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.component.ts", result); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.component.html", new string[0]); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.component.css", new string[0]); return(Task.CompletedTask); }
public async Task Handle(Request request, CancellationToken cancellationToken) { if (!string.IsNullOrEmpty(request.Entity)) { await _mediator.Send(new GenerateEditOverlayComponentCommand.Request(request.Options)); return; } var namePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Name); var nameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Name); var nameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name); var template = _templateLocator.Get("GenerateComponentCommand"); var tokens = new Dictionary <string, string> { { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace }, { "{{ nameSnakeCase }}", nameSnakeCase }, { "{{ prefix }}", "app" }, { "{{ namePascalCase }}", namePascalCase } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.component.ts", result); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.component.html", new string[0]); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.component.css", new string[0]); await Task.CompletedTask; }
public async Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var namePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Name); var nameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Name); var entityNamePascalCasePlural = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity, true); var template = request.Name.Contains("Created") || request.Name.Contains("NameChanged") ? _templateLocator.Get("GenerateDomainEventWithNameCommand") : _templateLocator.Get("GenerateDomainEventCommand"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace }, { "{{ namePascalCase }}", namePascalCase }, { "{{ nameCamelCase }}", nameCamelCase }, { "{{ entityNamePascalCasePlural }}", entityNamePascalCasePlural } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{namePascalCase}.cs", result); }
public async Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var entityNamePascalCasePlural = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity, true); var entityNameCamelCasePlural = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity, true); var templateScenarios = _templateLocator.Get("GenerateTestScenariosCommand"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ entityNamePascalCasePlural }}", entityNamePascalCasePlural }, { "{{ entityNameCamelCasePlural }}", entityNameCamelCasePlural }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace } }; var resultScenarios = _templateProcessor.ProcessTemplate(templateScenarios, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{entityNamePascalCase}Scenarios.cs", resultScenarios); await _mediator.Send(new GenerateTestScenarioBaseCommand.Request(request.Options)); }
public Task Handle(Request request, CancellationToken cancellationToken) { foreach (var name in request.Name.Split(",")) { var templateName = name; var template = _templateLocator.Get(templateName.Replace(".", "")); var tokens = new Dictionary <string, string> { { "{{ rootNamespace }}", request.RootNamespace } }; var result = _templateProcessor.ProcessTemplate(template, tokens); var relativePath = $"{result[0]}{name.Split("_")[0]}"; relativePath.Replace(@"\", "//"); Console.WriteLine(relativePath); result = result.Skip(1).ToArray(); _fileWriter.WriteAllLines($"{request.SolutionDirectory}//{relativePath}", result); } return(Task.CompletedTask); }
public Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var entityNamePascalCasePlural = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity, true); var serviceNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.ServiceName); var template = _templateLocator.Get("GenerateClientCommand"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNamePascalCasePlural }}", entityNamePascalCasePlural }, { "{{ entityNameLowerCasePlural }}", entityNamePascalCasePlural.ToLower() }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace }, { "{{ serviceNamePascalCase }}", serviceNamePascalCase } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{entityNamePascalCasePlural}Client.cs", result); return(Task.CompletedTask); }
public async Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var template = _templateLocator.Get("GenerateModelCommand"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{entityNamePascalCase}.cs", result); var notification = new EventSourcingModelCreated() { Entity = request.Entity, SolutionDirectory = request.SolutionDirectory, RootNamespace = request.RootNamespace }; await _mediator.Publish(notification); }
public Task Handle(Request request, CancellationToken cancellationToken) { var workingDirectory = System.Environment.CurrentDirectory; var template = _templateLocator.Get("GenerateCliSolutionCommand"); var tokens = new Dictionary <string, string> { { "{{ rootNamespace }}", request.RootNamespace }, { "{{ currentDirectory }}", CurrentDirectory }, }; foreach (var arguments in _templateProcessor.ProcessTemplate(template, tokens)) { if (arguments.StartsWith("cd")) { var path = arguments.Split(" ")[1]; if (path == CurrentDirectory) { workingDirectory = CurrentDirectory; } else { workingDirectory = $"{CurrentDirectory}\\{path}"; } } else { new Process { StartInfo = new ProcessStartInfo { WindowStyle = Hidden, FileName = "cmd.exe", Arguments = $"/C {arguments}", WorkingDirectory = workingDirectory } }.Start(); Thread.Sleep(1000); if (arguments.Contains("classlib") || arguments.Contains("angular") || arguments.Contains("xunit") || arguments.Contains("webapi")) { _fileWriter.WriteAllLines($"{workingDirectory}//codeGeneratorSettings.json", new List <string> { JsonConvert.SerializeObject(new { request.RootNamespace }) }.ToArray()); } } } return(Task.CompletedTask); }
private void InitializeFile() { var formattedDate = _dateTimeProvider.FormatDateFull(_creationDateTime); var nameLine = $"# {_logName} "; var dateLine = $"#### Initialized On {formattedDate} "; var initialLines = new [] { nameLine, dateLine, "---", "---", "" }; _wrappedFileWriter.CreateDirectory(_dirPath); _wrappedFileWriter.WriteAllLines(_filePath, initialLines); }
public void SaveText(string filePath, List <string> lines) { if (filePath.Length > 260) { throw new PathTooLongException("The path needs to be less than 261 characters long."); } string fileName = Path.GetFileName(filePath); _fileWriter.WriteAllLines(fileName, lines); }
public Task Handle(Request request, CancellationToken cancellationToken) { var nameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name); var template = _templateLocator.Get("GenerateNgScenarioCommand"); var result = _templateProcessor.ProcessTemplate(template, new Dictionary <string, string>()); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.scenario.ts", result); return(Task.CompletedTask); }
public Task Handle(Request request, CancellationToken cancellationToken) { var template = _templateLocator.Get("GenerateCodeGeneratorCommand"); if (template == null) { return(Task.CompletedTask); } var tokens = new Dictionary <string, string> { { "{{ name }}", request.Name }, { "{{ *namespace }}", request.Namespace }, { "{{ *rootNamespace }}", request.RootNamespace } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{request.Name}.cs", result); _fileWriter.WriteAllLines($"{request.Directory}//{request.Name}.txt", new string[0]); return(Task.CompletedTask); }
public Task Handle(Request request, CancellationToken cancellationToken) { var nameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Name); var nameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name); var template = _templateLocator.Get("GenerateValidatorCommand"); var tokens = new Dictionary <string, string> { { "{{ nameCamelCase }}", nameCamelCase }, }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.validator.ts", result); return(Task.CompletedTask); }
public Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var template = _templateLocator.Get("GenerateAppSettingsCommand"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//appsettings.json", result); return(Task.CompletedTask); }
public Task Handle(Request request, CancellationToken cancellationToken) { var entityNamePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Entity); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var template = _templateLocator.Get("Section1Step09Command"); var tokens = new Dictionary <string, string> { { "{{ entityNamePascalCase }}", entityNamePascalCase }, { "{{ entityNameCamelCase }}", entityNameCamelCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.SolutionDirectory}//src//{request.RootNamespace}.Core//Interfaces//IAppDbContext.cs", result); return(Task.CompletedTask); }
public async Task Handle(Request request, CancellationToken cancellationToken) { var namePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Name); var nameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Name); var nameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name); var entityNameCamelCase = _namingConventionConverter.Convert(NamingConvention.CamelCase, request.Entity); var template = _templateLocator.Get("GenerateOverlayServiceCommand"); var tokens = new Dictionary <string, string> { { "{{ namePascalCase }}", namePascalCase }, { "{{ nameCamelCase }}", nameCamelCase }, { "{{ nameSnakeCase }}", nameSnakeCase }, { "{{ namespace }}", request.Namespace }, { "{{ rootNamespace }}", request.RootNamespace }, { "{{ entityNameCamelCase }}", entityNameCamelCase } }; var result = _templateProcessor.ProcessTemplate(template, tokens); _fileWriter.WriteAllLines($"{request.Directory}//{nameSnakeCase}.ts", result); await _mediator.Send(new GenerateComponentCommand.Request(request.Options)); }
public Task Handle(Request request, CancellationToken cancellationToken) { var nameSnakeCase = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name); var namePascalCase = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Name); var nameSnakeCasePlural = _namingConventionConverter.Convert(NamingConvention.SnakeCase, request.Name, true); var namePascalCasePlural = _namingConventionConverter.Convert(NamingConvention.PascalCase, request.Name, true); var template = request.Name.ToLower() == "material" ? _templateLocator.Get("GenerateModuleCommand_Material") : _templateLocator.Get("GenerateModuleCommand"); var tokens = new Dictionary <string, string> { { "{{ namePascalCase }}", namePascalCase }, { "{{ namePascalCasePlural }}", namePascalCasePlural } }; var result = _templateProcessor.ProcessTemplate(template, tokens); var filename = request.Name.ToLower() == "material" ? "material" : nameSnakeCasePlural; _fileWriter.WriteAllLines($"{request.Directory}//{filename}.module.ts", result); return(Task.CompletedTask); }
public void PrintPetEntries(List <PetEntryModel> petEntry, string filename) { var entries = CommaDelimitedStringBuilder.ConvertPetEntriesToCommaDelimitedStrings(petEntry); _fileWriter.WriteAllLines(filename, entries); }
public void WriteAllLines(string[] lines) { _fileWriter.WriteAllLines(_file.FullName, lines); }