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

推荐订阅源

D
DataBreaches.Net
SecWiki News
SecWiki News
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
P
Palo Alto Networks Blog
V
Vulnerabilities – Threatpost
Project Zero
Project Zero
WordPress大学
WordPress大学
NISL@THU
NISL@THU
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Privacy & Cybersecurity Law Blog
Jina AI
Jina AI
AWS News Blog
AWS News Blog
Scott Helme
Scott Helme
Martin Fowler
Martin Fowler
C
Cybersecurity and Infrastructure Security Agency CISA
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
小众软件
小众软件
I
Intezer
A
Arctic Wolf
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
O
OpenAI News
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
Latest news
Latest news
G
GRAHAM CLULEY
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
N
News and Events Feed by Topic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V2EX - 技术
V2EX - 技术
Stack Overflow Blog
Stack Overflow Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
LINUX DO - 最新话题
博客园 - Franky
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
P
Proofpoint News Feed
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
F
Full Disclosure
Security Latest
Security Latest

博客园 - 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)    收藏  举报

刷新页面返回顶部