Skip to content

Commit

Permalink
DNN-4432 Handle popups for URLs that already have a query string (Pul…
Browse files Browse the repository at this point in the history
…l Request #31)
  • Loading branch information
cnurse committed Dec 17, 2013
1 parent 5957f82 commit 8f632a5
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions DNN Platform/Library/Common/Utilities/CBO.cs
Expand Up @@ -410,8 +410,7 @@ private static void HydrateObject(object hydratedObject, IDataReader dr)
}
else if (coloumnValue is IConvertible)
{
objPropertyInfo.SetValue(hydratedObject, Convert.ChangeType(coloumnValue, propType),
null);
objPropertyInfo.SetValue(hydratedObject, ChangeType(coloumnValue, propType), null);
}
else
{
Expand All @@ -424,6 +423,43 @@ private static void HydrateObject(object hydratedObject, IDataReader dr)
}
}

/// <summary>
/// Changes type of an object, taking into account Nullable types
/// </summary>
/// <param name="obj"></param>
/// <param name="type"></param>
/// <returns></returns>
static object ChangeType(object obj, Type type)
{
Type u = Nullable.GetUnderlyingType(type);

if (u != null)
{
if (obj == null)
{
return GetDefault(type);
}

return Convert.ChangeType(obj, u);
}
return Convert.ChangeType(obj, type);
}

/// <summary>
/// Returns default value for a type - i.e. null for reference types and default value for value types
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
static object GetDefault(Type type)
{
if (type.IsValueType)
{
return Activator.CreateInstance(type);
}

return null;
}

#endregion

#region Object Mapping Helper Methods
Expand Down

0 comments on commit 8f632a5

Please sign in to comment.