File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -1282,14 +1282,20 @@ private ICurrentSessionContext BuildCurrentSessionContext()
1282
1282
try
1283
1283
{
1284
1284
var implClass = ReflectHelper . ClassForName ( impl ) ;
1285
- if ( ! typeof ( ISessionFactoryAwareCurrentSessionContext ) . IsAssignableFrom ( implClass ) )
1285
+ var constructor = implClass . GetConstructor ( new [ ] { typeof ( ISessionFactoryImplementor ) } ) ;
1286
+ ICurrentSessionContext context ;
1287
+ if ( constructor != null )
1286
1288
{
1287
- return ( ICurrentSessionContext ) Activator . CreateInstance ( implClass , this ) ;
1289
+ context = ( ICurrentSessionContext ) constructor . Invoke ( new object [ ] { this } ) ;
1290
+ }
1291
+ else
1292
+ {
1293
+ context = ( ICurrentSessionContext ) Environment . ObjectsFactory . CreateInstance ( implClass ) ;
1294
+ }
1295
+ if ( context is ISessionFactoryAwareCurrentSessionContext sessionFactoryAwareContext )
1296
+ {
1297
+ sessionFactoryAwareContext . SetFactory ( this ) ;
1288
1298
}
1289
-
1290
- var context = ( ISessionFactoryAwareCurrentSessionContext ) Environment . ObjectsFactory . CreateInstance ( implClass ) ;
1291
- context . SetFactory ( this ) ;
1292
- return context ;
1293
1299
}
1294
1300
catch ( Exception e )
1295
1301
{
You can’t perform that action at this time.
0 commit comments