Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Checks to ArgumentNullException #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Slapper.AutoMapper/Slapper.AutoMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public static T MapDynamic<T>( object dynamicObject, bool keepCache = true)
/// <exception cref="ArgumentException">Exception that is thrown when the <paramref name="dynamicObject"/> cannot be converted to an IDictionary of type string and object.</exception>
public static object MapDynamic(Type type, object dynamicObject, bool keepCache = true)
{
if (type == null) throw new ArgumentNullException(nameof(type));

if (dynamicObject == null)
{
return type.IsValueType ? Activator.CreateInstance(type) : null;
Expand Down Expand Up @@ -128,6 +130,8 @@ public static IEnumerable<T> MapDynamic<T>( IEnumerable<object> dynamicListOfPro
/// <exception cref="ArgumentException">Exception that is thrown when the <paramref name="dynamicListOfProperties"/> cannot be converted to an IDictionary of type string and object.</exception>
public static IEnumerable<object> MapDynamic(Type type, IEnumerable<object> dynamicListOfProperties, bool keepCache = true)
{
if (type == null) throw new ArgumentNullException(nameof(type));

if (dynamicListOfProperties == null)
return new List<object>();

Expand Down Expand Up @@ -169,6 +173,8 @@ public static T Map<T>( IDictionary<string, object> listOfProperties, bool keepC
/// <returns>The specified Type</returns>
public static object Map(Type type, IDictionary<string, object> listOfProperties, bool keepCache = true)
{
if (type == null) throw new ArgumentNullException(nameof(type));

var propertiesList = new List<IDictionary<string, object>> { listOfProperties };

return Map(type, propertiesList, keepCache).FirstOrDefault();
Expand Down Expand Up @@ -201,6 +207,8 @@ public static IEnumerable<T> Map<T>( IEnumerable<IDictionary<string, object>> li
/// <returns>List of specified Type</returns>
public static IEnumerable<object> Map(Type type, IEnumerable<IDictionary<string, object>> listOfProperties, bool keepCache = true)
{
if (type == null) throw new ArgumentNullException(nameof(type));

var instanceCache = new Dictionary<object, object>();

foreach (var properties in listOfProperties)
Expand Down