3
3
using System . Collections . Generic ;
4
4
using System . Linq . Expressions ;
5
5
using System . Reflection ;
6
+ using NHibernate . Mapping . ByCode . Impl . CustomizersImpl ;
7
+ using NHibernate . Util ;
6
8
7
9
namespace NHibernate . Mapping . ByCode
8
10
{
@@ -41,7 +43,6 @@ public interface IBasePlainPropertyContainerMapper<TContainer> : IMinimalPlainPr
41
43
void Component < TComponent > ( Expression < Func < TContainer , TComponent > > property , Action < IComponentMapper < TComponent > > mapping ) ;
42
44
void Component < TComponent > ( Expression < Func < TContainer , TComponent > > property ) ;
43
45
void Component < TComponent > ( Expression < Func < TContainer , IDictionary > > property , TComponent dynamicComponentTemplate , Action < IDynamicComponentMapper < TComponent > > mapping ) ;
44
- void Component < TComponent > ( Expression < Func < TContainer , IDictionary < string , object > > > property , TComponent dynamicComponentTemplate , Action < IDynamicComponentMapper < TComponent > > mapping ) where TComponent : class ;
45
46
46
47
void Component < TComponent > ( string notVisiblePropertyOrFieldName , Action < IComponentMapper < TComponent > > mapping ) ;
47
48
void Component < TComponent > ( string notVisiblePropertyOrFieldName ) ;
@@ -56,4 +57,19 @@ public interface IPlainPropertyContainerMapper<TContainer> : IBasePlainPropertyC
56
57
void OneToOne < TProperty > ( Expression < Func < TContainer , TProperty > > property , Action < IOneToOneMapper < TProperty > > mapping ) where TProperty : class ;
57
58
void OneToOne < TProperty > ( string notVisiblePropertyOrFieldName , Action < IOneToOneMapper < TProperty > > mapping ) where TProperty : class ;
58
59
}
59
- }
60
+
61
+ public static class BasePlainPropertyContainerMapperExtensions
62
+ {
63
+ //6.0 TODO: Merge into IBasePlainPropertyContainerMapper<> interface
64
+ public static void Component < TContainer , TComponent > (
65
+ this IBasePlainPropertyContainerMapper < TContainer > mapper ,
66
+ Expression < Func < TContainer , IDictionary < string , object > > > property ,
67
+ TComponent dynamicComponentTemplate ,
68
+ Action < IDynamicComponentMapper < TComponent > > mapping ) where TComponent : class
69
+ {
70
+ var customizer = ReflectHelper . CastOrThrow < PropertyContainerCustomizer < TContainer > > (
71
+ mapper , "mapping a generic <string, object> dictionary as a dynamic component" ) ;
72
+ customizer . Component ( property , dynamicComponentTemplate , mapping ) ;
73
+ }
74
+ }
75
+ }
0 commit comments