##// END OF EJS Templates
Added methods for parameter checks
cin -
r51:2c332a9c64c0 default
parent child
Show More
@@ -2,11 +2,29
2 2 using System.Collections.Generic;
3 3 using System.Linq;
4 4 using System.Text;
5 using System.Text.RegularExpressions;
5 6
6 7 namespace Implab
7 8 {
8 9 public static class Safe
9 10 {
11 public static void ArgumentMatch(string param, string name, Regex rx) {
12 if (rx == null)
13 throw new ArgumentNullException("rx");
14 if (!rx.IsMatch(param))
15 throw new ArgumentException(String.Format("A prameter value must match {0}", rx), name);
16 }
17
18 public static void ArgumentNotEmpty(string param, string name) {
19 if (String.IsNullOrEmpty(param))
20 throw new ArgumentException("A parameter can't be empty", name);
21 }
22
23 public static void ArgumentNotNull(object param, string name) {
24 if (param == null)
25 throw new ArgumentNullException(name);
26 }
27
10 28 public static void Dispose<T>(T obj) where T : class
11 29 {
12 30 var disp = obj as IDisposable;
General Comments 0
You need to be logged in to leave comments. Login now