-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrecondition.cs
28 lines (25 loc) · 880 Bytes
/
Precondition.cs
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
using System;
namespace OAuth2Manager
{
public static class Precondition
{
public static void NotNull(object obj, string parameterName = "", string message = "")
{
if (obj == null) throw new ArgumentNullException(parameterName, message);
}
public static void NotNullOrEmpty(string value, string parameterName = "", string message = "")
{
switch (value)
{
case null:
throw new ArgumentNullException(parameterName, message);
case "":
throw new ArgumentException(message, parameterName);
}
}
public static void Requires(bool condition, string parameterName = "", string message = "")
{
if (!condition) throw new ArgumentException(message, parameterName);
}
}
}