|
From: <fab...@us...> - 2011-04-19 18:05:05
|
Revision: 5721
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5721&view=rev
Author: fabiomaulo
Date: 2011-04-19 18:04:58 +0000 (Tue, 19 Apr 2011)
Log Message:
-----------
Refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs 2011-04-19 17:50:26 UTC (rev 5720)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs 2011-04-19 18:04:58 UTC (rev 5721)
@@ -1035,9 +1035,7 @@
IEnumerable<MemberInfo> persistentProperties =
membersProvider.GetComponentMembers(componentType).Where(p => modelInspector.IsPersistentProperty(p));
- MemberInfo parentReferenceProperty = modelInspector.IsComponent(propertiesContainerType)
- ? persistentProperties.FirstOrDefault(pp => pp.GetPropertyOrFieldType() == propertiesContainerType)
- : null;
+ MemberInfo parentReferenceProperty = GetComponentParentReferenceProperty(persistentProperties, propertiesContainerType);
if (parentReferenceProperty != null)
{
componentMapper.Parent(parentReferenceProperty,
@@ -1054,6 +1052,13 @@
});
}
+ protected MemberInfo GetComponentParentReferenceProperty(IEnumerable<MemberInfo> persistentProperties, System.Type propertiesContainerType)
+ {
+ return modelInspector.IsComponent(propertiesContainerType)
+ ? persistentProperties.FirstOrDefault(pp => pp.GetPropertyOrFieldType() == propertiesContainerType)
+ : null;
+ }
+
private void MapBag(MemberInfo member, PropertyPath propertyPath, System.Type propertyType, ICollectionPropertiesContainerMapper propertiesContainer,
System.Type propertiesContainerType)
{
@@ -1232,26 +1237,24 @@
public void Map(ICollectionElementRelation relation)
{
relation.Component(x =>
- {
- IEnumerable<MemberInfo> persistentProperties = GetPersistentProperties(componentType);
+ {
+ IEnumerable<MemberInfo> persistentProperties = GetPersistentProperties(componentType);
- MemberInfo parentReferenceProperty = domainInspector.IsComponent(ownerType)
- ? persistentProperties.FirstOrDefault(pp => pp.GetPropertyOrFieldType() == ownerType)
- : null;
- if (parentReferenceProperty != null)
- {
- x.Parent(parentReferenceProperty,
- componentParentMapper =>
- {
+ MemberInfo parentReferenceProperty = modelMapper.GetComponentParentReferenceProperty(persistentProperties, ownerType);
+ if (parentReferenceProperty != null)
+ {
+ x.Parent(parentReferenceProperty,
+ componentParentMapper =>
+ {
/* TODO */
- }
- );
- }
- customizersHolder.InvokeCustomizers(componentType, x);
+ }
+ );
+ }
+ customizersHolder.InvokeCustomizers(componentType, x);
- var propertyPath = new PropertyPath(null, collectionMember);
- MapProperties(componentType, propertyPath, x, persistentProperties.Where(pi => pi != parentReferenceProperty));
- });
+ var propertyPath = new PropertyPath(null, collectionMember);
+ MapProperties(componentType, propertyPath, x, persistentProperties.Where(pi => pi != parentReferenceProperty));
+ });
}
public void MapCollectionProperties(ICollectionPropertiesMapper mapped) {}
@@ -1294,7 +1297,7 @@
IEnumerable<MemberInfo> componentProperties = GetPersistentProperties(componentPropertyType);
- MemberInfo parentReferenceProperty = componentProperties.FirstOrDefault(pp => pp.GetPropertyOrFieldType() == componentOwnerType);
+ MemberInfo parentReferenceProperty = modelMapper.GetComponentParentReferenceProperty(componentProperties, componentOwnerType);
if (parentReferenceProperty != null)
{
x.Parent(parentReferenceProperty, componentParentMapper =>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|