Beispiel #1
0
        private bool GenerateRepoFile(Table table)
        {
            var entityName = ToEntityName(table);
            var fileName   = entityName + "Repository.cs";
            var item       = _repoDirectory.ProjectItems.FindByName(fileName);

            if (item != null)
            {
                return(false);
            }

            _tablePropertiesConfig.Clear();

            //使用模板格式化字符串。
            var code = ItemCodeTemplate.GetRepositoryFileCode(
                this.DomainName, this.DomainName + ".Repositories", entityName, _domainBaseEntityName
                );

            //写到文件,并加入到项目中。
            var file = Path.Combine(Path.GetDirectoryName(_repoDirectory.get_FileNames(1)), fileName);

            File.WriteAllText(file, code);
            _repoDirectory.ProjectItems.AddFromFile(file);
            return(true);
        }
Beispiel #2
0
        private string RenderRepoByTemplate(CodeClass repo)
        {
            string domainNamespace = null;

            if (ParseDomainNamespace(repo, out domainNamespace))
            {
                var entity = Helper.GetEntityNameForRepository(repo);

                var res = ItemCodeTemplate.GetRepositoryFileCode(
                    domainNamespace, repo.Namespace.Name, entity
                    );

                return(res);
            }

            return(string.Empty);
        }