File tree Expand file tree Collapse file tree 6 files changed +56
-9
lines changed
FluentNHibernate.Testing/PersistenceModelTests Expand file tree Collapse file tree 6 files changed +56
-9
lines changed Original file line number Diff line number Diff line change 1
- using System ;
2
- using System . Collections . Generic ;
3
1
using System . Linq ;
4
2
using FluentNHibernate . Mapping ;
5
3
using FluentNHibernate . Mapping . Providers ;
@@ -13,13 +11,13 @@ namespace FluentNHibernate.Testing.PersistenceModelTests
13
11
[ TestFixture ]
14
12
public class SeparateSubclassVisitorFixture
15
13
{
16
- private IList < IIndeterminateSubclassMappingProvider > providers ;
14
+ private IIndeterminateSubclassMappingProviderCollection providers ;
17
15
private ClassMapping fooMapping ;
18
16
19
17
[ SetUp ]
20
18
public void SetUp ( )
21
19
{
22
- providers = new List < IIndeterminateSubclassMappingProvider > ( ) ;
20
+ providers = new IndeterminateSubclassMappingProviderCollection ( ) ;
23
21
}
24
22
25
23
[ Test ]
Original file line number Diff line number Diff line change 425
425
<Compile Include =" Mapping\NaturalIdPart.cs" />
426
426
<Compile Include =" Mapping\Providers\IElementMappingProvider.cs" />
427
427
<Compile Include =" Mapping\Providers\IExternalComponentMappingProvider.cs" />
428
+ <Compile Include =" Mapping\Providers\IIndeterminateSubclassMappingProviderCollection.cs" />
428
429
<Compile Include =" Mapping\Providers\INaturalIdMappingProvider.cs" />
430
+ <Compile Include =" Mapping\Providers\IndeterminateSubclassMappingProviderCollection.cs" />
429
431
<Compile Include =" Mapping\Providers\INestedCompositeElementMappingProvider.cs" />
430
432
<Compile Include =" Mapping\Providers\IPropertyMappingProvider.cs" />
431
433
<Compile Include =" Mapping\Providers\IReferenceComponentMappingProvider.cs" />
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+
4
+ namespace FluentNHibernate . Mapping . Providers
5
+ {
6
+ public interface IIndeterminateSubclassMappingProviderCollection : IEnumerable < IIndeterminateSubclassMappingProvider >
7
+ {
8
+ void Add ( IIndeterminateSubclassMappingProvider item ) ;
9
+ bool IsTypeMapped ( Type type ) ;
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections ;
3
+ using System . Collections . Generic ;
4
+
5
+ namespace FluentNHibernate . Mapping . Providers
6
+ {
7
+ /// <summary>
8
+ /// This collection optimizes search for already mapped types in subclasses providers. Matters in models with huge inheritance trees.
9
+ /// </summary>
10
+ public class IndeterminateSubclassMappingProviderCollection : IIndeterminateSubclassMappingProviderCollection
11
+ {
12
+ private readonly List < IIndeterminateSubclassMappingProvider > providers = new List < IIndeterminateSubclassMappingProvider > ( ) ;
13
+ private readonly HashSet < Type > mappedTypes = new HashSet < Type > ( ) ;
14
+
15
+ public IEnumerator < IIndeterminateSubclassMappingProvider > GetEnumerator ( )
16
+ {
17
+ return providers . GetEnumerator ( ) ;
18
+ }
19
+
20
+ IEnumerator IEnumerable . GetEnumerator ( )
21
+ {
22
+ return GetEnumerator ( ) ;
23
+ }
24
+
25
+ public void Add ( IIndeterminateSubclassMappingProvider item )
26
+ {
27
+ providers . Add ( item ) ;
28
+ mappedTypes . Add ( item . EntityType ) ;
29
+ }
30
+
31
+ public bool IsTypeMapped ( Type type )
32
+ {
33
+ return mappedTypes . Contains ( type ) ;
34
+ }
35
+ }
36
+ }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public class PersistenceModel
24
24
{
25
25
protected readonly IList < IMappingProvider > classProviders = new List < IMappingProvider > ( ) ;
26
26
protected readonly IList < IFilterDefinition > filterDefinitions = new List < IFilterDefinition > ( ) ;
27
- protected readonly IList < IIndeterminateSubclassMappingProvider > subclassProviders = new List < IIndeterminateSubclassMappingProvider > ( ) ;
27
+ protected readonly IIndeterminateSubclassMappingProviderCollection subclassProviders = new IndeterminateSubclassMappingProviderCollection ( ) ;
28
28
protected readonly IList < IExternalComponentMappingProvider > componentProviders = new List < IExternalComponentMappingProvider > ( ) ;
29
29
protected readonly IList < IComponentReferenceResolver > componentResolvers = new List < IComponentReferenceResolver >
30
30
{
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ namespace FluentNHibernate.Visitors
9
9
{
10
10
public class SeparateSubclassVisitor : DefaultMappingModelVisitor
11
11
{
12
- private readonly IList < IIndeterminateSubclassMappingProvider > subclassProviders ;
12
+ private readonly IIndeterminateSubclassMappingProviderCollection subclassProviders ;
13
13
14
- public SeparateSubclassVisitor ( IList < IIndeterminateSubclassMappingProvider > subclassProviders )
14
+ public SeparateSubclassVisitor ( IIndeterminateSubclassMappingProviderCollection subclassProviders )
15
15
{
16
16
this . subclassProviders = subclassProviders ;
17
17
}
@@ -65,9 +65,9 @@ private SubclassType GetSubclassType(ClassMapping mapping)
65
65
return SubclassType . Subclass ;
66
66
}
67
67
68
- private bool IsMapped ( Type type , IEnumerable < IIndeterminateSubclassMappingProvider > providers )
68
+ private bool IsMapped ( Type type , IIndeterminateSubclassMappingProviderCollection providers )
69
69
{
70
- return providers . Any ( x => x . EntityType == type ) ;
70
+ return providers . IsTypeMapped ( type ) ;
71
71
}
72
72
73
73
/// <summary>
You can’t perform that action at this time.
0 commit comments