2009-08-24 14 views

Répondre

1

Je ne pense pas qu'il soit mais vous pouvez soutenu facilement chercher et instancier intercepteurs à partir d'une section de configuration personnalisée:

NHibernate.Cfg.Configuration cfg = ... 
var interceptors = (NameValueCollection) ConfigurationManager.GetSection("nhibernate.interceptors"); 
foreach (string k in interceptors) 
    cfg.SetInterceptor((IInterceptor) Activator.CreateInstance(Type.GetType(k))); 

web.config:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<configSections> 
    <section name="nhibernate.interceptors" type="System.Configuration.NameValueSectionHandler, System" /> 
</configSections> 
<nhibernate.interceptors> 
    <add key="MyApp.Interceptors.SomeInterceptor, MyApp" value=""/> 
    <add key="MyApp.Interceptors.AnotherInterceptor, MyApp" value=""/> 
</nhibernate.interceptors> 
</configuration>