Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Bind form to a list as a complex propertyo
Browse files Browse the repository at this point in the history
  • Loading branch information
Søren Trudsø Mahon committed Aug 1, 2016
1 parent 1b32115 commit 28da65d
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 125 deletions.
15 changes: 15 additions & 0 deletions src/Nancy/Extensions/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,20 @@ public static NameValueCollection ToNameValueCollection(this IDictionary<string,
}
}
}

/// <summary>
/// Tries to get value from dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="source">The <see cref="IDictionary{TKey,TValue}"/> instance to get value from.</param>
/// <param name="key">The key to lookup.</param>
/// <returns></returns>
public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key)
{
TValue result;
source.TryGetValue(key, out result);
return result;
}
}
}
10 changes: 10 additions & 0 deletions src/Nancy/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public static Assembly GetAssembly(this Type source)
return source.GetTypeInfo().Assembly;
}

/// <summary>
/// Checks if a type is array, collection or enumerable
/// </summary>
/// <param name="source">The type to check.</param>
/// <returns></returns>
public static bool IsCollectionOrArrayOrEnumerable(this Type source)
{
return source.IsArray() || source.IsCollection() || source.IsEnumerable();
}

/// <summary>
/// Checks if a type is an array or not
/// </summary>
Expand Down

0 comments on commit 28da65d

Please sign in to comment.