XAF-DevExpress.ExpressApp.DC.Xpo.XpoTypeInfoSource 生成实体的过程-学习笔记
//目的,想自己生成实体类,不走dc的生成机制,所以研究一下此方法。
public void GenerateEntities(string generatedAssemblyFile)
{
lock (this.lockObjectForDC)
{
//此数组为要生成代码的接口类型
Type[] entityInterfaces = this.entitiesToGenerateInfo.GetEntityInterfaces();
if (!this.IsAlreadyBuild && (entityInterfaces.Length > ))
{
//生成过了,且有实体接口,有文件的情况下,直接加载
if (File.Exists(generatedAssemblyFile))
{
this.generatedAssembly = Assembly.LoadFrom(generatedAssemblyFile);
}
else
{
//没有文件,马上生成一个。
DCBuilder builder = new DCBuilder(this.typesInfo);
builder.Setup(this.entitiesToGenerateInfo, this.customLogics, this.existingImplementorsInfo);
this.generatedAssembly = builder.GetAssembly(generatedAssemblyFile);
}
this.ProcessGeneratedAssembly(this.generatedAssembly);
//遍历所有的实体类,即接口定义
Dictionary<Type, object> dictionary = new Dictionary<Type, object>();
foreach (Type type in entityInterfaces)
{
//没处理过的
if (!dictionary.ContainsKey(type))
{
dictionary.Add(type, null);
//标记为处理过。
//处理“基”接口
foreach (Type type2 in type.GetInterfaces())
{
//已经注册过的实体类中包含这个接,且,没处理过此接口时,把基接口也加进来
if (this.registeredEntityTypes.Contains(type2) && !dictionary.ContainsKey(type2))
{
dictionary.Add(type2, null);
}
}
}
}
foreach (Type type3 in dictionary.Keys)
{
//上面收集到了所有需要用到的接口,刷新类型信息。使用实际类型查找接口
this.typesInfo.RefreshInfo(type3);
Type entityTypeByInterface = this.GetEntityTypeByInterface(type3);
if (entityTypeByInterface != null)
{
this.typesInfo.RefreshInfo(entityTypeByInterface);
foreach (TypeInfo info in this.typesInfo.FindTypeInfo(entityTypeByInterface).RequiredTypes)
{
info.Refresh(true);
}
}
Type dataTypeByInterface = this.GetDataTypeByInterface(type3);
if (dataTypeByInterface != null)
{
this.typesInfo.RefreshInfo(dataTypeByInterface);
}
}
foreach (Type type6 in this.generatedAssembly.GetExportedTypes())
{
if (this.TypeIsKnown(type6))
{
TypeInfo info2 = this.typesInfo.FindTypeInfo(type6);
if ((info2 != null) && (info2.Source != this))
{
info2.Source = this;
this.typesInfo.RefreshInfo(type6);
//类typeinfo附source的值,即TypeInfoSource
}
}
}
}
}
}
XAF-DevExpress.ExpressApp.DC.Xpo.XpoTypeInfoSource 生成实体的过程-学习笔记的更多相关文章
- java生成二维码学习笔记
纠错等级: QRErrorCorrectLevel.L 7%的字码可被修正 QRErrorCorrectLevel.M 15%的字码可被修正 QRErrorCorrectLevel.Q 25%的字码可 ...
- T4模板根据DB生成实体类
1.前言 为什么会有这篇文章了,最近看到了一些框架,里面要写的代码太多了,故此就想偷懒,要是能写出一个T4模板,在数据库添加表后,根据模板就可以自动生成了类文件了,这样多好,心动不如行动.记得使用T4 ...
- 使用T4为数据库自动生成实体类
T4 (Text Template Transformation Toolkit) 是一个基于模板的代码生成器.使用T4你可以通过写一些ASP.NET-like模板,来生成C#, T-SQL, XML ...
- T4模板_根据DB生成实体类
为了减少重复劳动,可以通过T4读取数据库表结构,生成实体类,用下面的实例测试了一下 1.首先创建一个项目,并添加文本模板: 2.添加 文本模板: 3.向T4文本模板文件添加代码: <#@ tem ...
- 懒人小工具:T4生成实体类Model,Insert,Select,Delete以及导出Excel的方法
由于最近公司在用webform开发ERP,用到大量重复机械的代码,之前写了篇文章,懒人小工具:自动生成Model,Insert,Select,Delete以及导出Excel的方法,但是有人觉得这种方法 ...
- NHibernate生成实体类、xml映射文件
最近工作电脑装完win10后,之前使用的codeSmith安装不了,索性自己写一个. 界面比较简单,如下图: 第一行为Oracle数据库的连接字符串.连接成功后,填充表到第4行的下拉列表中. 第二行为 ...
- VS2015 +EF6 连接MYSQL数据库生成实体
VS2015 +EF6 连接MYSQL数据库生成实体 已安装软件:VS2015 XAMPP Control Panel(Mysql服务器) ...
- springmvc学习笔记--mybatis--使用插件自动生成实体和mapper
由于表对象在开发过程中会增删字段,有时候需要重新生成实体和对应的mapper,这时候可以通过mybatis的插件的生成. 优点是快速简洁,缺点同样很明显:覆盖.因此,通常是在第一次搭建框架的时候使用, ...
- spring boot 框架 启动更新项目,以及生成 "实体_"文件
1.更新项目 clean ---> 更新项目 ---> package--->refresh 即可.(这几个步骤一个不能够少) 2.项目中的类的依赖关系存在,但是无法导入依赖 m ...
随机推荐
- 记Git报错-Everything up-to-date
文:铁乐与猫 今天git push 到github远程仓库的时候,出现报错"Everything up-to-date",严格来说也不算报错,它只是在告诉你,提交区所有的东西都是最 ...
- 如何创建一个Quartz.NET的工作,需要注射autofac
问题: 使用 Quartz.Net 做定时任务时,实现IJob对象的服务,Autofac不会自动注入,使用构造函数会直接出现异常,无法执行Execute方法. 解决方式 方法一: 使用 Autofac ...
- NCE3
Lesson1 A puma at large Pumas are large, cat-like animals which are found in America. When reports ...
- Fix for: Permission denied to access property 'toString'
Originally posted by rwolffgang here. Hi guys,when developing a game that runs in an iframe (Faceboo ...
- 安装配置maven私服-nexus
1.ubuntu下的Bundle安装方式 1.1. 去官网下载安装包:http://www.sonatype.org/nexus/ 我这里下载的是:nexus-2.8.1-01-bundle.zip, ...
- JedisPool无法获得资源问题
线上碰到一个问题:redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the ...
- zoc license code
点击导航栏上的zoc-about zoc,然后: 点击enter license: 然后输入内容即可: part A: 51698/01027/34713 part B: 00937 还有很多其他 ...
- js之radio应用实例
radio和checkbox还有select,可谓是前后端常用三剑客啊!特别是checkbox和select,关于这两个今天不讲,因为在下面这几篇文章,我已经比较详细的讲解了. SpringMVC之a ...
- django自带的登录验证功能
django自带的验证机制 from django.shortcuts import render, redirect from django.contrib.auth import authenti ...
- 多线程之线程间协作的两种方式:wait、notify、notifyAll和Condition
Java并发编程:线程间协作的两种方式:wait.notify.notifyAll和Condition 在前面我们将了很多关于同步的问题,然而在现实中,需要线程之间的协作.比如说最经典的生产者-消费者 ...