Skip to content

Commit ba756e1

Browse files
committed
Move AuxiliaryTypeFactory to static readonly
1 parent 3a4bac2 commit ba756e1

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

Orm/Xtensive.Orm/Orm/Building/Builders/ModelBuilder.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public TypeKey(string name, Type ownerType, Type targetType)
4949

5050
private static readonly ConcurrentDictionary<TypeKey, Lazy<Type>> GeneratedTypes = new ConcurrentDictionary<TypeKey, Lazy<Type>>();
5151

52+
private static readonly Func<TypeKey, Lazy<Type>> AuxiliaryTypeFactory = typeKey =>
53+
new Lazy<Type>(() => {
54+
var baseType = WellKnownOrmTypes.EntitySetItemOfT1T2.CachedMakeGenericType(typeKey.OwnerType, typeKey.TargetType);
55+
return TypeHelper.CreateInheritedDummyType(typeKey.Name, baseType, true);
56+
});
57+
5258
private readonly BuildingContext context;
5359
private readonly TypeBuilder typeBuilder;
5460
private readonly ModelDefBuilder modelDefBuilder;
@@ -431,13 +437,6 @@ private Type GenerateAuxiliaryType(AssociationInfo association)
431437
ownerType.Namespace,
432438
context.NameBuilder.BuildAssociationName(association));
433439

434-
static Lazy<Type> AuxiliaryTypeFactory(TypeKey typeKey) {
435-
return new Lazy<Type>(() => {
436-
var baseType = WellKnownOrmTypes.EntitySetItemOfT1T2.CachedMakeGenericType(typeKey.OwnerType, typeKey.TargetType);
437-
return TypeHelper.CreateInheritedDummyType(typeKey.Name, baseType, true);
438-
});
439-
};
440-
441440
return GeneratedTypes.GetOrAdd(new TypeKey(typeName, ownerType, targetType), AuxiliaryTypeFactory).Value;
442441
}
443442

0 commit comments

Comments
 (0)