forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssertUtils.cs
More file actions
35 lines (33 loc) · 989 Bytes
/
AssertUtils.cs
File metadata and controls
35 lines (33 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
namespace ServiceStack
{
public static class AssertUtils
{
public static void AreNotNull<T>(params T[] fields)
{
if (fields.Contains(default(T)))
{
throw new ArgumentNullException(typeof(T).Name);
}
}
/// <summary>
/// Asserts that the supplied arguments are not null.
///
/// AssertUtils.AreNotNull(new Dictionary<string,object>{ {"name",null} });
/// will throw new ArgumentNullException("name");
/// </summary>
/// <param name="fieldMap">The field map.</param>
public static void AreNotNull(IDictionary<string, object> fieldMap)
{
foreach (var pair in fieldMap)
{
if (pair.Value == null)
{
throw new ArgumentNullException(pair.Key);
}
}
}
}
}