Skip to content

Commit 123db33

Browse files
committed
Refactor GeneratedTypes dictionary
1 parent e3e4850 commit 123db33

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ public TypeKey(string name, Type ownerType, Type targetType) {
4444

4545
private const string GeneratedTypeNameFormat = "{0}.EntitySetItems.{1}";
4646

47-
private static ConcurrentDictionary<TypeKey, Lazy<Type>> generatedTypes = new ConcurrentDictionary<TypeKey, Lazy<Type>>();
47+
private static readonly ConcurrentDictionary<TypeKey, Lazy<Type>> GeneratedTypes = new ConcurrentDictionary<TypeKey, Lazy<Type>>();
48+
49+
private static readonly Func<TypeKey, Lazy<Type>> AuxiliaryTypeFactory = typeKey =>
50+
new Lazy<Type>(() => {
51+
var baseType = WellKnownOrmTypes.EntitySetItemOfT1T2.MakeGenericType(typeKey.OwnerType, typeKey.TargetType);
52+
return TypeHelper.CreateInheritedDummyType(typeKey.Name, baseType, true);
53+
});
54+
4855

4956
private readonly BuildingContext context;
5057
private readonly TypeBuilder typeBuilder;
@@ -428,14 +435,7 @@ private Type GenerateAuxiliaryType(AssociationInfo association)
428435
ownerType.Namespace,
429436
context.NameBuilder.BuildAssociationName(association));
430437

431-
static Lazy<Type> AuxiliaryTypeFactory(TypeKey typeKey) {
432-
return new Lazy<Type>(() => {
433-
var baseType = WellKnownOrmTypes.EntitySetItemOfT1T2.MakeGenericType(typeKey.OwnerType, typeKey.TargetType);
434-
return TypeHelper.CreateInheritedDummyType(typeKey.Name, baseType, true);
435-
});
436-
};
437-
438-
return generatedTypes.GetOrAdd(new TypeKey(typeName, ownerType, targetType), AuxiliaryTypeFactory).Value;
438+
return GeneratedTypes.GetOrAdd(new TypeKey(typeName, ownerType, targetType), AuxiliaryTypeFactory).Value;
439439
}
440440

441441
private void FindAndMarkInboundAndOutboundTypes(BuildingContext context)

0 commit comments

Comments
 (0)