惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - thh

svm资料收集 向量空间及其他相关数学结构 难题--autoconf、automake、libtool Linq 中不爽之处 关于UI设计的文章汇总 Window Live Writer LR 剖析器 MVP模式中的P和V关系 Guid、Int、BigInt编号的速度和存储空间的比较 静态构造函数线程安全的几个版本[转载] 区域性 ID 2155 (0x086B)不是受支持的区域性 解决方法 windbg给clr设置断点 python ip和int 互转函数 interface与pojo类之间的关系 关于OpenId Python SOAPpy访问asp.net web service 代码 Python SOAPpy 和 .net WebService NHibernate 代码生成工具 NHibernate使用笔记
Type.GetType 获得本Assembly以外的类型
thh · 2007-03-16 · via 博客园 - thh

   简而言之,就是相应AppDomain.的AssemblyResolve实现的。
   DynAssembly提供给动态载入的模块提供一个解析名字的机会。如下代码可以把NHibernate 的Hbm.xml 生成 数据库结构。

using System;
using System.Collections.Generic;
using System.Text;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;

namespace Hbm2Sql
{
    
class DynAssembly
    
{
        System.Reflection.Assembly _asm;

        
public DynAssembly(System.Reflection.Assembly asm)
        
{
            
this._asm = asm;
            AppDomain.CurrentDomain.AssemblyResolve 
+= new ResolveEventHandler(this.TypeResolve);
        }


        
public System.Reflection.Assembly TypeResolve(object sender, ResolveEventArgs args)
        
{
            
if (_asm.FullName.Contains(args.Name))
            
{
                
return _asm;
            }

            
return null;
        }

    }


    
class Program
    
{
        
static void Main(string[] args)
        
{
            
try
            
{
                
if (args.Length > 0)
                
{
                    System.Console.Write(
"命令行:");
                    System.Console.WriteLine(
string.Join(" ",args));

                    System.Reflection.Assembly asm 
= AppDomain.CurrentDomain.Load(System.Reflection.AssemblyName.GetAssemblyName(args[0]));
                    
new DynAssembly(asm);
                    NHibernate.Cfg.Configuration cfg 
= new Configuration().Configure()
                                                        .AddAssembly(asm);
                    SchemaExport export 
= new SchemaExport(cfg);
                    export.Create(
truefalse);
                }

            }

            
catch (System.Exception e)
            
{
                System.Console.Write(e.ToString());
            }

            
finally
            
{
                System.ConsoleKeyInfo i 
= System.Console.ReadKey();
            }

        }

    }

}

 posted on 2007-03-16 02:00  thh  阅读(1407)  评论(0)    收藏  举报

刷新页面返回顶部