LEFT | RIGHT |
(no file at all) | |
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 14 matching lines...) Expand all Loading... |
25 /// <summary>A utility class which contains helper methods and extension met
hods.</summary> | 25 /// <summary>A utility class which contains helper methods and extension met
hods.</summary> |
26 public static class Utilities | 26 public static class Utilities |
27 { | 27 { |
28 /// <summary>Returns the version of the core library.</summary> | 28 /// <summary>Returns the version of the core library.</summary> |
29 internal static string GetLibraryVersion() | 29 internal static string GetLibraryVersion() |
30 { | 30 { |
31 return Regex.Match(typeof(Utilities).Assembly.FullName, "Version=([\
\d\\.] )").Groups[1].ToString(); | 31 return Regex.Match(typeof(Utilities).Assembly.FullName, "Version=([\
\d\\.] )").Groups[1].ToString(); |
32 } | 32 } |
33 | 33 |
34 /// <summary>Throws an <seealso cref="System.ArgumentNullException"/> if
the object is null.</summary> | 34 /// <summary>Throws an <seealso cref="System.ArgumentNullException"/> if
the object is null.</summary> |
35 internal static void ThrowIfNull(this object obj, string paramName) | 35 internal static T ThrowIfNull<T>(this T obj, string paramName) |
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 |
| 42 return obj; |
41 } | 43 } |
42 | 44 |
43 /// <summary> | 45 /// <summary> |
44 /// Throws an <seealso cref="System.ArgumentNullException"/> if the stri
ng is <c>null</c> or empty. | 46 /// Throws an <seealso cref="System.ArgumentNullException"/> if the stri
ng is <c>null</c> or empty. |
45 /// </summary> | 47 /// </summary> |
46 /// <returns>The original string</returns> | 48 /// <returns>The original string</returns> |
47 internal static string ThrowIfNullOrEmpty(this string str, string paramN
ame) | 49 internal static string ThrowIfNullOrEmpty(this string str, string paramN
ame) |
48 { | 50 { |
49 if (string.IsNullOrEmpty(str)) | 51 if (string.IsNullOrEmpty(str)) |
50 { | 52 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 var enumType = o.GetType(); | 103 var enumType = o.GetType(); |
102 FieldInfo field = enumType.GetField(o.ToString()); | 104 FieldInfo field = enumType.GetField(o.ToString()); |
103 StringValueAttribute attribute = field.GetCustomAttribute<String
ValueAttribute>(); | 105 StringValueAttribute attribute = field.GetCustomAttribute<String
ValueAttribute>(); |
104 return attribute != null ? attribute.Text : o.ToString(); | 106 return attribute != null ? attribute.Text : o.ToString(); |
105 } | 107 } |
106 | 108 |
107 return o.ToString(); | 109 return o.ToString(); |
108 } | 110 } |
109 } | 111 } |
110 } | 112 } |
LEFT | RIGHT |