Пример #1
0
 public MediatRControllerDecorator(ControllerTemplate template, IApplication application)
 {
     _template    = template;
     _application = application;
     _template.AddTypeSource(CommandModelsTemplate.TemplateId);
     _template.AddTypeSource(QueryModelsTemplate.TemplateId);
     _template.AddTypeSource(DtoModelTemplate.TemplateId, "List<{0}>");
 }
Пример #2
0
        public void RenderControllerFile(List <SearchModel> search, List <EntityModel> entity)
        {
            if (!Directory.Exists(_outputPath + "Controller\\"))
            {
                Directory.CreateDirectory(_outputPath + "Controller\\");
            }
            var controllerTemplate = new ControllerTemplate(_projectName, _tableName, search, entity);
            var output             = controllerTemplate.TransformText();
            var outputpath         = _outputPath + "Controller\\" + NormalizeTableName + "Controller.cs";

            File.WriteAllText(outputpath, output);
        }
 private void GenerateController(CodeGenerateDto dto)
 {
     foreach (var entity in dto.Entities)
     {
         if (dto.ExceptApis.Contains(entity.Name, StringComparer.OrdinalIgnoreCase))
         {
             continue;
         }
         var controllerTemplate = new ControllerTemplate();
         controllerTemplate.Name    = entity.Name;
         controllerTemplate.Comment = entity.Comment;
         Directory.CreateDirectory($@"{dto.BasePath}\Web\Controllers");
         System.IO.File.WriteAllText($@"{dto.BasePath}\Web\Controllers\{entity.Name}Controller.cs", controllerTemplate.TransformText());
     }
 }
Пример #4
0
        public static void GenerateController(GeneratorParameters.GeneratorParameters generatorParameters)
        {
            ControllerTemplate template = new ControllerTemplate
            {
                //Create our session.
                Session = new Dictionary <string, object>()
            };

            template.Session["ClassName"]     = generatorParameters.Controller.Name;
            template.Session["Namespace"]     = generatorParameters.NamespaceName;
            template.Session["Model"]         = generatorParameters.Model.Name;
            template.Session["Extends"]       = generatorParameters.Controller.Extends;
            template.Session["BaseNamespace"] = generatorParameters.Controller.BaseNamespace;

            template.Initialize();

            string classDef = template.TransformText();

            File.WriteAllText($"{generatorParameters.OutputDir}/{generatorParameters.Controller.Name}.cs", classDef);
        }
Пример #5
0
 public override void Build(CompileBase compile, Foundation.Projects.ProjectDocument doc)
 {
     try
     {
         var serviceCompile = compile as ServiceCompile;
         if (serviceCompile != null)
         {
             var entity = serviceCompile.GetDocumentBody(doc) as EntityDefinition;
             if (entity != null && entity.Controller != null && entity.Members.Count > 0)
             {
                 var    data   = serviceCompile.Data.Controllers[doc.Id];
                 string result = new ControllerTemplate(data).TransformText();
                 serviceCompile.GenerateCode("Controllers", data.ClassName, result);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("DataControllterBuild:" + ex.ToString());
     }
 }
 public RolesAuthorizationDecorator(ControllerTemplate template, IApplication application)
 {
     _template    = template;
     _application = application;
 }
Пример #7
0
 public DbContextSaveControllerDecorator(ControllerTemplate template, IApplication application)
 {
     _template    = template;
     _application = application;
     Priority     = 100;
 }
 public ContractDispatchDecorator(ControllerTemplate template, IApplication application)
 {
     _template    = template;
     _application = application;
     _template.AddTypeSource(DtoModelTemplate.TemplateId, "List<{0}>");
 }
Пример #9
0
 public ControllerAuthenticationSchemesDecorator(ControllerTemplate template, IApplication application)
 {
     _template    = template;
     _application = application;
 }