/// <summary>
        /// Get Entities template file information.
        /// </summary>
        /// <returns>Dictionary of templates with file information.</returns>
        public Dictionary <string, TemplateFileInfo> GetEntitiesTemplateFileInfo(ITemplateFileService fileService)
        {
            var result = new Dictionary <string, TemplateFileInfo>
            {
                {
                    Constants.EntityTypeTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.CSharpTemplateDirectories.EntityTypeDirectory,
                        FileName          = Constants.EntityTypeTemplate + Constants.TemplateExtension
                    }
                },
            };

            foreach (var file in fileService.RetrieveAllFileNames(Constants.CSharpTemplateDirectories.EntityTypePartialsDirectory))
            {
                result.Add(file, new TemplateFileInfo()
                {
                    RelativeDirectory = Constants.CSharpTemplateDirectories.EntityTypePartialsDirectory,
                    FileName          = file + Constants.TemplateExtension
                });
            }

            return(result);
        }
        public ItemToTemplateCommand()
        {
            Text = "Copy to template...";
            SortingValue = 1000;

            _fileService = new TemplateFileService();
            _templateEngineService = new TemplateEngineService();
        }
Пример #3
0
 private void SetTemplates(ITemplateFileService templateFileService)
 {
     this.DataContextTemplates = templateFileService.DataContextTemplates;
     this.EntityTemplates      = templateFileService.EntityTemplates;
     this.MappingTemplates     = templateFileService.MappingTemplates;
     this.WcfDataServiceDataContextTemplates = templateFileService.WcfDataServiceDataContextTemplates;
     this.WcfDataServiceClientTemplates      = templateFileService.WcfDataServiceClientTemplates;
 }
Пример #4
0
        public SettingsViewModel(ICodeGenSettings settings, ITemplateFileService templateFileService, ISchemaService schemaService, IEventAggregator eventAggregator)
        {
            this.Settings  = settings;
            this.Databases = new ObservableCollection <IDatabase>(schemaService.Databases);
            this.SetTemplates(templateFileService);

            this.LoadSchemaCommand         = new Command(_ => this.PublishLoadSchemaEvent());
            this.CustomizeSchemaSqlCommand = new Command(x => eventAggregator.GetEvent <CustomSchemaSqlViewVisibilityChangedEvent>().Publish(true));
            this._eventAggregator          = eventAggregator;
            this._eventAggregator.GetEvent <SchemaProviderNameChangedEvent>().Subscribe(this.UpdateSelectedProvider);
        }
Пример #5
0
 /// <summary>
 /// Constructor for the Handlebars scaffolding generator.
 /// </summary>
 /// <param name="fileService">Provides files to the template service.</param>
 /// <param name="dbContextTemplateService">Template service for DbContext generator.</param>
 /// <param name="entityTypeTemplateService">Template service for the entity types generator.</param>
 /// <param name="cSharpDbContextGenerator">DbContext generator.</param>
 /// <param name="cSharpEntityTypeGenerator">Entity types generator.</param>
 public HbsCSharpScaffoldingGenerator(
     ITemplateFileService fileService,
     IDbContextTemplateService dbContextTemplateService,
     IEntityTypeTemplateService entityTypeTemplateService,
     ICSharpDbContextGenerator cSharpDbContextGenerator,
     ICSharpEntityTypeGenerator cSharpEntityTypeGenerator)
     : base(fileService)
 {
     DbContextTemplateService  = dbContextTemplateService ?? throw new ArgumentNullException(nameof(dbContextTemplateService));
     EntityTypeTemplateService = entityTypeTemplateService ?? throw new ArgumentNullException(nameof(entityTypeTemplateService));
     CSharpDbContextGenerator  = cSharpDbContextGenerator ?? throw new ArgumentNullException(nameof(cSharpDbContextGenerator));
     CSharpEntityTypeGenerator = cSharpEntityTypeGenerator ?? throw new ArgumentNullException(nameof(cSharpEntityTypeGenerator));
 }
        /// <summary>
        /// Get Entities template file information.
        /// </summary>
        /// <returns>Dictionary of templates with file information.</returns>
        public Dictionary <string, TemplateFileInfo> GetEntitiesTemplateFileInfo(ITemplateFileService fileService)
        {
            var result = new Dictionary <string, TemplateFileInfo>
            {
                {
                    Constants.EntityTypeTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.CSharpTemplateDirectories.EntityTypeDirectory,
                        FileName          = Constants.EntityTypeTemplate + Constants.TemplateExtension
                    }
                },
            };

            result = fileService.FindAllPartialTemplates(result, Constants.CSharpTemplateDirectories.EntityTypePartialsDirectory);
            return(result);
        }
Пример #7
0
        /// <summary>
        /// Get DbContext template file information.
        /// </summary>
        /// <returns>Dictionary of templates with file information.</returns>
        public Dictionary <string, TemplateFileInfo> GetDbContextTemplateFileInfo(ITemplateFileService fileService)
        {
            var result = new Dictionary <string, TemplateFileInfo>
            {
                {
                    Constants.DbContextTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.TypeScriptTemplateDirectories.DbContextDirectory,
                        FileName          = Constants.DbContextTemplate + Constants.TemplateExtension
                    }
                }
            };

            result = fileService.FindAllPartialTemplates(result, Constants.TypeScriptTemplateDirectories.DbContextPartialsDirectory);
            return(result);
        }
        /// <summary>
        /// Get DbContext template file information.
        /// </summary>
        /// <returns>Dictionary of templates with file information.</returns>
        public Dictionary <string, TemplateFileInfo> GetDbContextTemplateFileInfo(ITemplateFileService fileService)
        {
            var result = new Dictionary <string, TemplateFileInfo>
            {
                {
                    Constants.DbContextTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.CSharpTemplateDirectories.DbContextDirectory,
                        FileName          = Constants.DbContextTemplate + Constants.TemplateExtension
                    }
                },
                {
                    Constants.DbContextImportTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.CSharpTemplateDirectories.DbContextPartialsDirectory,
                        FileName          = Constants.DbContextImportTemplate + Constants.TemplateExtension
                    }
                },
                {
                    Constants.DbContextCtorTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.CSharpTemplateDirectories.DbContextPartialsDirectory,
                        FileName          = Constants.DbContextCtorTemplate + Constants.TemplateExtension
                    }
                },
                {
                    Constants.DbContextDbSetsTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.CSharpTemplateDirectories.DbContextPartialsDirectory,
                        FileName          = Constants.DbContextDbSetsTemplate + Constants.TemplateExtension
                    }
                },
            };

            return(result);
        }
Пример #9
0
        /// <summary>
        /// Get Entities template file information.
        /// </summary>
        /// <returns>Dictionary of templates with file information.</returns>
        public Dictionary <string, TemplateFileInfo> GetEntitiesTemplateFileInfo(ITemplateFileService fileService)
        {
            var result = new Dictionary <string, TemplateFileInfo>
            {
                {
                    Constants.EntityTypeTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.TypeScriptTemplateDirectories.EntityTypeDirectory,
                        FileName          = Constants.EntityTypeTemplate + Constants.TemplateExtension
                    }
                },
                {
                    Constants.EntityTypeImportTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.TypeScriptTemplateDirectories.EntityTypePartialsDirectory,
                        FileName          = Constants.EntityTypeImportTemplate + Constants.TemplateExtension
                    }
                },
                {
                    Constants.EntityTypeCtorTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.TypeScriptTemplateDirectories.EntityTypePartialsDirectory,
                        FileName          = Constants.EntityTypeCtorTemplate + Constants.TemplateExtension
                    }
                },
                {
                    Constants.EntityTypePropertyTemplate,
                    new TemplateFileInfo
                    {
                        RelativeDirectory = Constants.TypeScriptTemplateDirectories.EntityTypePartialsDirectory,
                        FileName          = Constants.EntityTypePropertyTemplate + Constants.TemplateExtension
                    }
                },
            };

            return(result);
        }
 /// <summary>
 /// Constructor for entity type template service.
 /// </summary>
 /// <param name="fileService">Template file service.</param>
 /// <param name="languageService">Template language service.</param>
 public HbsEntityTypeTemplateService(ITemplateFileService fileService,
                                     ITemplateLanguageService languageService) : base(fileService, languageService)
 {
     EntitiesTemplateFiles = LanguageService.GetEntitiesTemplateFileInfo(fileService);
 }
 /// <summary>
 /// Constructor for the DbContext template service.
 /// </summary>
 /// <param name="fileService">Template file service.</param>
 public HbsDbContextTemplateService(ITemplateFileService fileService) : base(fileService)
 {
 }
Пример #12
0
 /// <summary>
 /// Constructor for the template service.
 /// </summary>
 /// <param name="fileService">Template file service.</param>
 /// <param name="languageService">Template language service.</param>
 protected HbsTemplateService(ITemplateFileService fileService,
                              ITemplateLanguageService languageService)
 {
     FileService     = fileService;
     LanguageService = languageService;
 }
Пример #13
0
 /// <summary>
 /// Constructor for the DbContext template service.
 /// </summary>
 /// <param name="fileService">Template file service.</param>
 /// <param name="languageService">Template language service.</param>
 public HbsDbContextTemplateService(ITemplateFileService fileService,
                                    ITemplateLanguageService languageService) : base(fileService, languageService)
 {
     DbContextTemplateFiles = LanguageService.GetDbContextTemplateFileInfo(fileService);
 }
Пример #14
0
 /// <summary>
 /// Constructor for the template service.
 /// </summary>
 /// <param name="fileService">Template file service.</param>
 protected HbsTemplateService(ITemplateFileService fileService)
 {
     FileService = fileService;
 }
 /// <summary>
 /// Constructor for entity type template service.
 /// </summary>
 /// <param name="fileService">Template file service.</param>
 public HbsEntityTypeTemplateService(ITemplateFileService fileService) : base(fileService)
 {
 }