Skip to content

Commit

Permalink
Resolved #2671: AbpNHibernateInterceptor.NormalizeDateTimePropertiesF…
Browse files Browse the repository at this point in the history
…orComponentType should check for null componentObject
  • Loading branch information
hikalkan committed Nov 14, 2017
1 parent adb6b78 commit e0fcbd0
Showing 1 changed file with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,32 +223,39 @@ private static void NormalizeDateTimePropertiesForEntity(object[] state, IList<I

private static void NormalizeDateTimePropertiesForComponentType(object componentObject, IType type)
{
if (componentObject == null)
{
return;
}

var componentType = type as ComponentType;
if (componentType != null)
if (componentType == null)
{
for (int i = 0; i < componentType.PropertyNames.Length; i++)
{
var propertyName = componentType.PropertyNames[i];
if (componentType.Subtypes[i].IsComponentType)
{
var value = componentObject.GetType().GetProperty(propertyName).GetValue(componentObject, null);
NormalizeDateTimePropertiesForComponentType(value, componentType.Subtypes[i]);
}
return;
}

if (componentType.Subtypes[i].ReturnedClass != typeof(DateTime) && componentType.Subtypes[i].ReturnedClass != typeof(DateTime?))
{
continue;
}
for (int i = 0; i < componentType.PropertyNames.Length; i++)
{
var propertyName = componentType.PropertyNames[i];
if (componentType.Subtypes[i].IsComponentType)
{
var value = componentObject.GetType().GetProperty(propertyName).GetValue(componentObject, null);
NormalizeDateTimePropertiesForComponentType(value, componentType.Subtypes[i]);
}

var dateTime = componentObject.GetType().GetProperty(propertyName).GetValue(componentObject) as DateTime?;
if (componentType.Subtypes[i].ReturnedClass != typeof(DateTime) && componentType.Subtypes[i].ReturnedClass != typeof(DateTime?))
{
continue;
}

if (!dateTime.HasValue)
{
continue;
}
var dateTime = componentObject.GetType().GetProperty(propertyName).GetValue(componentObject) as DateTime?;

componentObject.GetType().GetProperty(propertyName).SetValue(componentObject, Clock.Normalize(dateTime.Value));
if (!dateTime.HasValue)
{
continue;
}

componentObject.GetType().GetProperty(propertyName).SetValue(componentObject, Clock.Normalize(dateTime.Value));
}
}

Expand Down

0 comments on commit e0fcbd0

Please sign in to comment.