zoukankan      html  css  js  c++  java
  • 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 > 0)) {
            //生成过了,且有实体接口,有文件的情况下,直接加载
    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 } } } } } }
  • 相关阅读:
    SQL Server误区30日谈Day15CheckPoint只会将已提交的事务写入磁盘
    SQL Server误区30日谈Day16数据的损坏和修复
    【译】Windows Azure迁移生命周期概览
    【译】实现为Windows Azure制定的迁移计划
    SQL Server误区30日谈Day18有关FileStream的存储,垃圾回收以及其它
    【译】为迁移到Windows Azure制定规划
    SQL Server误区30日谈Day14清除日志后会将相关的LSN填零初始化
    SQL PASS北京用户群成功举办第一次线下活动,性能调优PPT分享
    Windows Azure虚拟机概览
    SQL Pass北京将举办第一次线下活动,欢迎大家报名
  • 原文地址:https://www.cnblogs.com/foreachlife/p/xpotypeinfosource_GenerateEntities.html
Copyright © 2011-2022 走看看