@@ -15,13 +15,13 @@ namespace FluentNHibernate.Visitors;
1515
1616public class ConventionVisitor : DefaultMappingModelVisitor
1717{
18- readonly Dictionary < Collection , Action < MappingModel . Collections . CollectionMapping > > collections ;
18+ readonly Dictionary < Collection , Action < CollectionMapping > > collections ;
1919 readonly IConventionFinder finder ;
2020 Type currentType ;
2121
2222 public ConventionVisitor ( IConventionFinder finder )
2323 {
24- collections = new Dictionary < Collection , Action < MappingModel . Collections . CollectionMapping > >
24+ collections = new Dictionary < Collection , Action < CollectionMapping > >
2525 {
2626 { Collection . Array , ProcessArray } ,
2727 { Collection . Bag , ProcessBag } ,
@@ -36,24 +36,21 @@ public override void ProcessHibernateMapping(HibernateMapping hibernateMapping)
3636 {
3737 var conventions = finder . Find < IHibernateMappingConvention > ( ) ;
3838
39- Apply < IHibernateMappingInspector , IHibernateMappingInstance > ( conventions ,
40- new HibernateMappingInstance ( hibernateMapping ) ) ;
39+ Apply ( conventions , new HibernateMappingInstance ( hibernateMapping ) ) ;
4140 }
4241
4342 public override void ProcessId ( IdMapping idMapping )
4443 {
4544 var conventions = finder . Find < IIdConvention > ( ) ;
4645
47- Apply < IIdentityInspector , IIdentityInstance > ( conventions ,
48- new IdentityInstance ( idMapping ) ) ;
46+ Apply ( conventions , new IdentityInstance ( idMapping ) ) ;
4947 }
5048
5149 public override void ProcessCompositeId ( CompositeIdMapping idMapping )
5250 {
5351 var conventions = finder . Find < ICompositeIdentityConvention > ( ) ;
5452
55- Apply < ICompositeIdentityInspector , ICompositeIdentityInstance > ( conventions ,
56- new CompositeIdentityInstance ( idMapping ) ) ;
53+ Apply ( conventions , new CompositeIdentityInstance ( idMapping ) ) ;
5754 }
5855
5956 public override void ProcessClass ( ClassMapping classMapping )
@@ -62,46 +59,40 @@ public override void ProcessClass(ClassMapping classMapping)
6259
6360 currentType = classMapping . Type ;
6461
65- Apply < IClassInspector , IClassInstance > ( conventions ,
66- new ClassInstance ( classMapping ) ) ;
62+ Apply ( conventions , new ClassInstance ( classMapping ) ) ;
6763 }
6864
6965 public override void ProcessProperty ( PropertyMapping propertyMapping )
7066 {
7167 var conventions = finder . Find < IPropertyConvention > ( ) ;
7268
73- Apply < IPropertyInspector , IPropertyInstance > ( conventions ,
74- new PropertyInstance ( propertyMapping ) ) ;
69+ Apply ( conventions , new PropertyInstance ( propertyMapping ) ) ;
7570 }
7671
7772 public override void ProcessColumn ( ColumnMapping columnMapping )
7873 {
7974 var conventions = finder . Find < IColumnConvention > ( ) ;
8075
81- Apply < IColumnInspector , IColumnInstance > ( conventions ,
82- new ColumnInstance ( currentType , columnMapping ) ) ;
76+ Apply ( conventions , new ColumnInstance ( currentType , columnMapping ) ) ;
8377 }
8478
8579 public override void ProcessCollection ( CollectionMapping mapping )
8680 {
8781 var generalConventions = finder . Find < ICollectionConvention > ( ) ;
8882
89- Apply < ICollectionInspector , ICollectionInstance > ( generalConventions ,
90- new CollectionInstance ( mapping ) ) ;
83+ Apply ( generalConventions , new CollectionInstance ( mapping ) ) ;
9184
9285 if ( mapping . Relationship is ManyToManyMapping )
9386 {
9487 var conventions = finder . Find < IHasManyToManyConvention > ( ) ;
9588
96- Apply < IManyToManyCollectionInspector , IManyToManyCollectionInstance > ( conventions ,
97- new ManyToManyCollectionInstance ( mapping ) ) ;
89+ Apply ( conventions , new ManyToManyCollectionInstance ( mapping ) ) ;
9890 }
9991 else
10092 {
10193 var conventions = finder . Find < IHasManyConvention > ( ) ;
10294
103- Apply < IOneToManyCollectionInspector , IOneToManyCollectionInstance > ( conventions ,
104- new OneToManyCollectionInstance ( mapping ) ) ;
95+ Apply ( conventions , new OneToManyCollectionInstance ( mapping ) ) ;
10596 }
10697
10798 collections [ mapping . Collection ] ( mapping ) ;
@@ -112,65 +103,57 @@ void ProcessArray(CollectionMapping mapping)
112103 {
113104 var conventions = finder . Find < IArrayConvention > ( ) ;
114105
115- Apply < IArrayInspector , IArrayInstance > ( conventions ,
116- new CollectionInstance ( mapping ) ) ;
106+ Apply ( conventions , new CollectionInstance ( mapping ) ) ;
117107 }
118108
119109 void ProcessBag ( CollectionMapping mapping )
120110 {
121111 var conventions = finder . Find < IBagConvention > ( ) ;
122112
123- Apply < IBagInspector , IBagInstance > ( conventions ,
124- new CollectionInstance ( mapping ) ) ;
113+ Apply ( conventions , new CollectionInstance ( mapping ) ) ;
125114 }
126115
127116 void ProcessList ( CollectionMapping mapping )
128117 {
129118 var conventions = finder . Find < IListConvention > ( ) ;
130119
131- Apply < IListInspector , IListInstance > ( conventions ,
132- new CollectionInstance ( mapping ) ) ;
120+ Apply ( conventions , new CollectionInstance ( mapping ) ) ;
133121 }
134122
135123 void ProcessMap ( CollectionMapping mapping )
136124 {
137125 var conventions = finder . Find < IMapConvention > ( ) ;
138126
139- Apply < IMapInspector , IMapInstance > ( conventions ,
140- new CollectionInstance ( mapping ) ) ;
127+ Apply ( conventions , new CollectionInstance ( mapping ) ) ;
141128 }
142129
143130 void ProcessSet ( CollectionMapping mapping )
144131 {
145132 var conventions = finder . Find < ISetConvention > ( ) ;
146133
147- Apply < ISetInspector , ISetInstance > ( conventions ,
148- new CollectionInstance ( mapping ) ) ;
134+ Apply ( conventions , new CollectionInstance ( mapping ) ) ;
149135 }
150136#pragma warning restore 612 , 618
151137
152138 public override void ProcessManyToOne ( ManyToOneMapping mapping )
153139 {
154140 var conventions = finder . Find < IReferenceConvention > ( ) ;
155141
156- Apply < IManyToOneInspector , IManyToOneInstance > ( conventions ,
157- new ManyToOneInstance ( mapping ) ) ;
142+ Apply ( conventions , new ManyToOneInstance ( mapping ) ) ;
158143 }
159144
160145 public override void ProcessVersion ( VersionMapping mapping )
161146 {
162147 var conventions = finder . Find < IVersionConvention > ( ) ;
163148
164- Apply < IVersionInspector , IVersionInstance > ( conventions ,
165- new VersionInstance ( mapping ) ) ;
149+ Apply ( conventions , new VersionInstance ( mapping ) ) ;
166150 }
167151
168152 public override void ProcessOneToOne ( OneToOneMapping mapping )
169153 {
170154 var conventions = finder . Find < IHasOneConvention > ( ) ;
171155
172- Apply < IOneToOneInspector , IOneToOneInstance > ( conventions ,
173- new OneToOneInstance ( mapping ) ) ;
156+ Apply ( conventions , new OneToOneInstance ( mapping ) ) ;
174157 }
175158
176159 public override void ProcessSubclass ( SubclassMapping subclassMapping )
@@ -179,15 +162,13 @@ public override void ProcessSubclass(SubclassMapping subclassMapping)
179162 {
180163 var conventions = finder . Find < ISubclassConvention > ( ) ;
181164
182- Apply < ISubclassInspector , ISubclassInstance > ( conventions ,
183- new SubclassInstance ( subclassMapping ) ) ;
165+ Apply ( conventions , new SubclassInstance ( subclassMapping ) ) ;
184166 }
185167 else
186168 {
187169 var conventions = finder . Find < IJoinedSubclassConvention > ( ) ;
188170
189- Apply < IJoinedSubclassInspector , IJoinedSubclassInstance > ( conventions ,
190- new JoinedSubclassInstance ( subclassMapping ) ) ;
171+ Apply ( conventions , new JoinedSubclassInstance ( subclassMapping ) ) ;
191172 }
192173 }
193174
@@ -197,71 +178,63 @@ public override void ProcessComponent(ComponentMapping mapping)
197178 {
198179 var conventions = finder . Find < IComponentConvention > ( ) ;
199180
200- Apply < IComponentInspector , IComponentInstance > ( conventions ,
201- new ComponentInstance ( mapping ) ) ;
181+ Apply ( conventions , new ComponentInstance ( mapping ) ) ;
202182 }
203183 else
204184 {
205185 var conventions = finder . Find < IDynamicComponentConvention > ( ) ;
206186
207- Apply < IDynamicComponentInspector , IDynamicComponentInstance > ( conventions ,
208- new DynamicComponentInstance ( mapping ) ) ;
187+ Apply ( conventions , new DynamicComponentInstance ( mapping ) ) ;
209188 }
210189 }
211190
212191 public override void ProcessIndex ( IndexMapping indexMapping )
213192 {
214193 var conventions = finder . Find < IIndexConvention > ( ) ;
215194
216- Apply < IIndexInspector , IIndexInstance > ( conventions ,
217- new IndexInstance ( indexMapping ) ) ;
195+ Apply ( conventions , new IndexInstance ( indexMapping ) ) ;
218196 }
219197
220198 public override void ProcessIndex ( IndexManyToManyMapping indexMapping )
221199 {
222200 var conventions = finder . Find < IIndexManyToManyConvention > ( ) ;
223201
224- Apply < IIndexManyToManyInspector , IIndexManyToManyInstance > ( conventions ,
225- new IndexManyToManyInstance ( indexMapping ) ) ;
202+ Apply ( conventions , new IndexManyToManyInstance ( indexMapping ) ) ;
226203 }
227204
228205 public override void ProcessJoin ( JoinMapping joinMapping )
229206 {
230207 var conventions = finder . Find < IJoinConvention > ( ) ;
231208
232- Apply < IJoinInspector , IJoinInstance > ( conventions ,
233- new JoinInstance ( joinMapping ) ) ;
209+ Apply ( conventions , new JoinInstance ( joinMapping ) ) ;
234210 }
235211
236212 public override void ProcessKeyProperty ( KeyPropertyMapping mapping )
237213 {
238214 var conventions = finder . Find < IKeyPropertyConvention > ( ) ;
239215
240- Apply < IKeyPropertyInspector , IKeyPropertyInstance > ( conventions ,
241- new KeyPropertyInstance ( mapping ) ) ;
216+ Apply ( conventions , new KeyPropertyInstance ( mapping ) ) ;
242217 }
243218
244219 public override void ProcessKeyManyToOne ( KeyManyToOneMapping mapping )
245220 {
246221 var conventions = finder . Find < IKeyManyToOneConvention > ( ) ;
247222
248- Apply < IKeyManyToOneInspector , IKeyManyToOneInstance > ( conventions ,
249- new KeyManyToOneInstance ( mapping ) ) ;
223+ Apply ( conventions , new KeyManyToOneInstance ( mapping ) ) ;
250224 }
251225
252226 public override void ProcessAny ( AnyMapping mapping )
253227 {
254228 var conventions = finder . Find < IAnyConvention > ( ) ;
255229
256- Apply < IAnyInspector , IAnyInstance > ( conventions ,
257- new AnyInstance ( mapping ) ) ;
230+ Apply ( conventions , new AnyInstance ( mapping ) ) ;
258231 }
259232
260- static void Apply < TInspector , TInstance > ( IEnumerable conventions , TInstance instance )
233+ static void Apply < TInspector , TInstance > ( IEnumerable < IConvention < TInspector , TInstance > > conventions , TInstance instance )
261234 where TInspector : IInspector
262- where TInstance : TInspector
235+ where TInstance : class , TInspector
263236 {
264- foreach ( IConvention < TInspector , TInstance > convention in conventions )
237+ foreach ( var convention in conventions )
265238 {
266239 var criteria = new ConcreteAcceptanceCriteria < TInspector > ( ) ;
267240 var acceptance = convention as IConventionAcceptance < TInspector > ;
0 commit comments