LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2010 Google Inc | 2 Copyright 2010 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
(...skipping 25 matching lines...) Expand all Loading... |
36 { | 36 { |
37 if (obj == null) | 37 if (obj == null) |
38 { | 38 { |
39 throw new ArgumentNullException(paramName); | 39 throw new ArgumentNullException(paramName); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 /// <summary> | 43 /// <summary> |
44 /// Throws an <seealso cref="System.ArgumentNullException"/> if the stri
ng is <c>null</c> or empty. | 44 /// Throws an <seealso cref="System.ArgumentNullException"/> if the stri
ng is <c>null</c> or empty. |
45 /// </summary> | 45 /// </summary> |
| 46 /// <returns>The original string</returns> |
46 internal static string ThrowIfNullOrEmpty(this string str, string paramN
ame) | 47 internal static string ThrowIfNullOrEmpty(this string str, string paramN
ame) |
47 { | 48 { |
48 if (string.IsNullOrEmpty(str)) | 49 if (string.IsNullOrEmpty(str)) |
49 { | 50 { |
50 throw new ArgumentException("Parameter was empty", paramName); | 51 throw new ArgumentException("Parameter was empty", paramName); |
51 } | 52 } |
52 return str; | 53 return str; |
53 } | 54 } |
54 | 55 |
55 /// <summary>Returns <c>true</c> in case the enumerable is <c>null</c> o
r empty. </summary> | 56 /// <summary>Returns <c>true</c> in case the enumerable is <c>null</c> o
r empty. </summary> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 var enumType = o.GetType(); | 101 var enumType = o.GetType(); |
101 FieldInfo field = enumType.GetField(o.ToString()); | 102 FieldInfo field = enumType.GetField(o.ToString()); |
102 StringValueAttribute attribute = field.GetCustomAttribute<String
ValueAttribute>(); | 103 StringValueAttribute attribute = field.GetCustomAttribute<String
ValueAttribute>(); |
103 return attribute != null ? attribute.Text : o.ToString(); | 104 return attribute != null ? attribute.Text : o.ToString(); |
104 } | 105 } |
105 | 106 |
106 return o.ToString(); | 107 return o.ToString(); |
107 } | 108 } |
108 } | 109 } |
109 } | 110 } |
LEFT | RIGHT |