Mercurial > pub > ImplabNet
comparison Implab/Safe.cs @ 121:62d2f1e98c4e v2
working version of AsyncQueue and batch operations
tests
author | cin |
---|---|
date | Mon, 12 Jan 2015 18:19:41 +0300 |
parents | 2573b562e328 |
children | f7b2b8bfbb8c |
comparison
equal
deleted
inserted
replaced
120:f1b897999260 | 121:62d2f1e98c4e |
---|---|
7 | 7 |
8 namespace Implab | 8 namespace Implab |
9 { | 9 { |
10 public static class Safe | 10 public static class Safe |
11 { | 11 { |
12 public static void ArgumentMatch(string param, string name, Regex rx) { | 12 public static void ArgumentMatch(string value, string paramName, Regex rx) { |
13 if (rx == null) | 13 if (rx == null) |
14 throw new ArgumentNullException("rx"); | 14 throw new ArgumentNullException("rx"); |
15 if (!rx.IsMatch(param)) | 15 if (!rx.IsMatch(value)) |
16 throw new ArgumentException(String.Format("The prameter value must match {0}", rx), name); | 16 throw new ArgumentException(String.Format("The prameter value must match {0}", rx), paramName); |
17 } | 17 } |
18 | 18 |
19 public static void ArgumentNotEmpty(string param, string name) { | 19 public static void ArgumentNotEmpty(string value, string paramName) { |
20 if (String.IsNullOrEmpty(param)) | 20 if (String.IsNullOrEmpty(value)) |
21 throw new ArgumentException("The parameter can't be empty", name); | 21 throw new ArgumentException("The parameter can't be empty", paramName); |
22 } | 22 } |
23 | 23 |
24 public static void ArgumentNotEmpty<T>(T[] param, string name) { | 24 public static void ArgumentNotEmpty<T>(T[] value, string paramName) { |
25 if (param == null || param.Length == 0) | 25 if (value == null || value.Length == 0) |
26 throw new ArgumentException("The array must be not emty", name); | 26 throw new ArgumentException("The array must be not emty", paramName); |
27 } | 27 } |
28 | 28 |
29 public static void ArgumentNotNull(object param, string name) { | 29 public static void ArgumentNotNull(object value, string paramName) { |
30 if (param == null) | 30 if (value == null) |
31 throw new ArgumentNullException(name); | 31 throw new ArgumentNullException(paramName); |
32 } | 32 } |
33 | 33 |
34 public static void ArgumentInRange(int arg, int min, int max, string name) { | 34 public static void ArgumentInRange(int value, int min, int max, string paramName) { |
35 if (arg < min || arg > max) | 35 if (value < min || value > max) |
36 throw new ArgumentOutOfRangeException(name); | 36 throw new ArgumentOutOfRangeException(paramName); |
37 } | 37 } |
38 | 38 |
39 public static void Dispose<T>(T obj) where T : class | 39 public static void Dispose<T>(T obj) where T : class |
40 { | 40 { |
41 var disp = obj as IDisposable; | 41 var disp = obj as IDisposable; |