public static List <TemplateEntity> GetEntitys()
        {
            List <TemplateEntity> result = new List <TemplateEntity>();
            string entityDir             = ProjectContainer.DomainEntity.ToDirectory();

            string[] files = Directory.GetFiles(entityDir, "*.cs");
            if (null == files || files.Length == 0)
            {
                throw new Exception("Entity2Code DomainEntity ProjectItem is Null");
            }
            string entityDir1 = ProjectContainer.Data2Object.ToDirectory();

            string[] files1 = Directory.GetFiles(entityDir1, "*.cs");
            if (null == files1 || files1.Length == 0)
            {
                throw new Exception("Entity2Code DomainDTO ProjectItem is Null");
            }
            foreach (string file in files)
            {
                string entity = Path.GetFileNameWithoutExtension(file);

                string data2obj = ModelNameConverter.GetData2Obj(entity);
                data2obj = files1.Where(t => t.ToLower().Contains(data2obj.ToLower())).FirstOrDefault();
                data2obj = Path.GetFileNameWithoutExtension(data2obj);
                result.Add(new TemplateEntity()
                {
                    Entity = entity, Data2Obj = data2obj
                });
            }

            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// 获取所有领域层实体信息
 /// </summary>
 /// <param name="overRead">是否重新读</param>
 /// <returns></returns>
 public static List <TemplateEntity> GetEntitys(bool overRead)
 {
     if (_entitys == null || overRead)
     {
         _entitys = new List <TemplateEntity>();
         if (SolutionCommon.infrastryctType == InfrastructType.DbFirst)
         {
             if (ProjectContainer.DomainEntity == null)
             {
                 throw new Exception("Entity2Code DomainEntity Project Can not be Find");
             }
             string   entityDir = ProjectContainer.DomainEntity.ToDirectory();
             string[] files     = Directory.GetFiles(entityDir, "*.cs");
             if (null == files || files.Length == 0)
             {
                 throw new Exception("Entity2Code DomainEntity ProjectItem is Null");
             }
             foreach (string file in files)
             {
                 string entity = Path.GetFileNameWithoutExtension(file);
                 _entitys.Add(new TemplateEntity()
                 {
                     Entity = entity, Data2Obj = ModelNameConverter.GetData2Obj(entity)
                 });
             }
         }
         else
         {
             foreach (Table item in CodeFirstLogic.GetTables())
             {
                 _entitys.Add(new TemplateEntity()
                 {
                     Entity = item.Name, Data2Obj = item.NameHumanCase
                 });
             }
         }
     }
     return(_entitys);
 }