Пример #1
0
        private void CreateIndexFile()
        {
            ExecuteOnStepMessage(StepInput.ChmStrings.CreateIndex);
            var indexHtmlFile = Path.Combine(StepInput.TmpPath, StepInput.SDProject.ProjectName.Replace(" ", "") + "-Index.html");
            var template      = new IndexTemplate();

            File.WriteAllText(indexHtmlFile, template.TransformText());
        }
        public void IndexView_Template_Test()
        {
            var template = new IndexTemplate(new EntityInfo()
            {
                Id = _entityId
            }, ApplicationId);
            var output = template.TransformText();

            Assert.NotNull(output);
            Assert.NotEmpty(output);
            Assert.Contains($"@model IEnumerable<{ApplicationId}.Backend.DataModels.{_entityId}>", output);
        }
        public void IndexView_Template_NullParameter_Test()
        {
            var template = new IndexTemplate(null, null);

            Assert.Throws <ArgumentNullException>(() => template.TransformText());
        }
        private void TransformViews(SmartAppInfo manifest)
        {
            var enabledEntities = manifest.DataModel.Entities.Where(e => !e.IsAbstract);

            foreach (var entity in enabledEntities)
            {
                var applicationId = manifest.Id;

                var createTemplate = new CreateTemplate(entity, applicationId);
                var editTemplate   = new EditTemplate(entity, applicationId);
                var detailTemplate = new DetailsTemplate(entity, applicationId);
                var deleteTemplate = new DeleteTemplate(entity, applicationId);
                var indexTemplate  = new IndexTemplate(entity, applicationId);

                _writingService.WriteFile(Path.Combine(_context.BasePath, createTemplate.OutputPath, entity.Id, "Create.cshtml"), createTemplate.TransformText());
                _writingService.WriteFile(Path.Combine(_context.BasePath, editTemplate.OutputPath, entity.Id, "Edit.cshtml"), editTemplate.TransformText());
                _writingService.WriteFile(Path.Combine(_context.BasePath, deleteTemplate.OutputPath, entity.Id, "Delete.cshtml"), deleteTemplate.TransformText());
                _writingService.WriteFile(Path.Combine(_context.BasePath, detailTemplate.OutputPath, entity.Id, "Details.cshtml"), detailTemplate.TransformText());
                _writingService.WriteFile(Path.Combine(_context.BasePath, indexTemplate.OutputPath, entity.Id, "Index.cshtml"), indexTemplate.TransformText());
            }
        }