33using System . Collections . Generic ;
44using System . Linq . Expressions ;
55using System . Reflection ;
6+ using NHibernate . Mapping . ByCode . Impl . CustomizersImpl ;
7+ using NHibernate . Util ;
68
79namespace NHibernate . Mapping . ByCode
810{
@@ -41,7 +43,6 @@ public interface IBasePlainPropertyContainerMapper<TContainer> : IMinimalPlainPr
4143 void Component < TComponent > ( Expression < Func < TContainer , TComponent > > property , Action < IComponentMapper < TComponent > > mapping ) ;
4244 void Component < TComponent > ( Expression < Func < TContainer , TComponent > > property ) ;
4345 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 ;
4546
4647 void Component < TComponent > ( string notVisiblePropertyOrFieldName , Action < IComponentMapper < TComponent > > mapping ) ;
4748 void Component < TComponent > ( string notVisiblePropertyOrFieldName ) ;
@@ -56,4 +57,19 @@ public interface IPlainPropertyContainerMapper<TContainer> : IBasePlainPropertyC
5657 void OneToOne < TProperty > ( Expression < Func < TContainer , TProperty > > property , Action < IOneToOneMapper < TProperty > > mapping ) where TProperty : class ;
5758 void OneToOne < TProperty > ( string notVisiblePropertyOrFieldName , Action < IOneToOneMapper < TProperty > > mapping ) where TProperty : class ;
5859 }
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