public void RenderServiceFile(List <SearchModel> models) { if (!Directory.Exists(_outputPath + "Services\\" + NormalizeTableName + "\\")) { Directory.CreateDirectory(_outputPath + "Services\\" + NormalizeTableName + "\\"); } var serviceTemplate = new ServiceTemplate(_projectName, _tableName.Replace("_", ""), models); var output = serviceTemplate.TransformText(); var outputPath = _outputPath + "Services\\" + NormalizeTableName + "\\" + NormalizeTableName + "Service.cs"; File.WriteAllText(outputPath, output); var interfaceTemplate = new IServiceTemplate(_projectName, NormalizeTableName); var iOutPut = interfaceTemplate.TransformText(); var iOutPutPath = _outputPath + "Services\\" + NormalizeTableName + "\\I" + NormalizeTableName + "Service.cs"; File.WriteAllText(iOutPutPath, iOutPut); }
private void TransformServices(SmartAppInfo manifest) { bool result = true; var enabledEntities = manifest.DataModel.Entities.Where(e => !e.IsAbstract && e.AllProperties().FirstOrDefault(p => p.IsKey) != null); foreach (var entity in enabledEntities) { if (!result) { break; } var template = new ServiceTemplate(entity, manifest.Id, Constants.Version); result = _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath, $"{entity.Id}Service.g.cs"), template.TransformText()); } }
private void GenerateService(CodeGenerateDto dto) { foreach (var entity in dto.Entities) { if (dto.ExceptServices.Contains(entity.Name, StringComparer.OrdinalIgnoreCase)) { continue; } var serviceTemplate = new ServiceTemplate(); serviceTemplate.Name = entity.Name; Directory.CreateDirectory($@"{dto.BasePath}\Service"); System.IO.File.WriteAllText($@"{dto.BasePath}\Service\{entity.Name}Service.cs", serviceTemplate.TransformText()); } }