Merge pull request #856 from madewokherd/textcontrol
[mono.git] / mcs / class / corlib / System.Reflection / CustomAttributeExtensions.cs
1 //
2 // CustomAttributeExtensions.cs
3 //
4 // Authors:
5 //      Marek Safar  <marek.safar@gmail.com>
6 //
7 // Copyright (C) 2012 Xamarin, Inc (http://www.xamarin.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 #if NET_4_5
30
31 using System;
32 using System.Collections.Generic;
33
34 namespace System.Reflection
35 {
36         public static class CustomAttributeExtensions
37         {
38                 public static T GetCustomAttribute<T> (this Assembly element) where T : Attribute
39                 {
40                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
41                 }
42
43                 public static T GetCustomAttribute<T> (this MemberInfo element) where T : Attribute
44                 {
45                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
46                 }
47
48                 public static T GetCustomAttribute<T> (this Module element) where T : Attribute
49                 {
50                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
51                 }
52
53                 public static T GetCustomAttribute<T> (this ParameterInfo element) where T : Attribute
54                 {
55                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
56                 }
57
58                 public static T GetCustomAttribute<T> (this MemberInfo element, bool inherit) where T : Attribute
59                 {
60                         return (T) Attribute.GetCustomAttribute (element, typeof (T), inherit);
61                 }
62
63                 public static T GetCustomAttribute<T> (this ParameterInfo element, bool inherit) where T : Attribute
64                 {
65                         return (T) Attribute.GetCustomAttribute (element, typeof (T), inherit);
66                 }
67
68                 public static Attribute GetCustomAttribute (this Assembly element, Type attributeType)
69                 {
70                         return Attribute.GetCustomAttribute (element, attributeType);
71                 }
72
73                 public static Attribute GetCustomAttribute (this MemberInfo element, Type attributeType)
74                 {
75                         return Attribute.GetCustomAttribute (element, attributeType);
76                 }
77
78                 public static Attribute GetCustomAttribute (this MemberInfo element, Type attributeType, bool inherit)
79                 {
80                         return Attribute.GetCustomAttribute (element, attributeType, inherit);
81                 }
82
83                 public static Attribute GetCustomAttribute (this Module element, Type attributeType)
84                 {
85                         return Attribute.GetCustomAttribute (element, attributeType);
86                 }
87
88                 public static Attribute GetCustomAttribute (this ParameterInfo element, Type attributeType)
89                 {
90                         return Attribute.GetCustomAttribute (element, attributeType);
91                 }
92
93                 public static Attribute GetCustomAttribute (this ParameterInfo element, Type attributeType, bool inherit)
94                 {
95                         return Attribute.GetCustomAttribute (element, attributeType, inherit);
96                 }
97
98                 public static IEnumerable<Attribute> GetCustomAttributes (this Assembly element)
99                 {
100                         return Attribute.GetCustomAttributes (element);
101                 }
102
103                 public static IEnumerable<Attribute> GetCustomAttributes (this Assembly element, Type attributeType)
104                 {
105                         return Attribute.GetCustomAttributes (element, attributeType);
106                 }
107
108                 public static IEnumerable<Attribute> GetCustomAttributes (this Module element)
109                 {
110                         return Attribute.GetCustomAttributes (element);
111                 }
112
113                 public static IEnumerable<Attribute> GetCustomAttributes (this Module element, Type attributeType)
114                 {
115                         return Attribute.GetCustomAttributes (element);
116                 }
117
118                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element)
119                 {
120                         return Attribute.GetCustomAttributes (element);
121                 }
122
123                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element, bool inherit)
124                 {
125                         return Attribute.GetCustomAttributes (element, inherit);
126                 }
127
128                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element, Type attributeType)
129                 {
130                         return Attribute.GetCustomAttributes (element, attributeType);
131                 }
132
133                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element, Type attributeType,
134                                                                           bool inherit)
135                 {
136                         return Attribute.GetCustomAttributes (element, attributeType, inherit);
137                 }
138
139                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element)
140                 {
141                         return Attribute.GetCustomAttributes (element);
142                 }
143
144                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element, bool inherit)
145                 {
146                         return Attribute.GetCustomAttributes (element, inherit);
147                 }
148
149                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element, Type attributeType)
150                 {
151                         return Attribute.GetCustomAttributes (element, attributeType);
152                 }
153
154                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element, Type attributeType,
155                                                                           bool inherit)
156                 {
157                         return Attribute.GetCustomAttributes (element, attributeType, inherit);
158                 }
159
160                 public static IEnumerable<T> GetCustomAttributes<T> (this Assembly element) where T : Attribute
161                 {
162                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
163                 }
164
165                 public static IEnumerable<T> GetCustomAttributes<T> (this MemberInfo element) where T : Attribute
166                 {
167                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
168                 }
169
170                 public static IEnumerable<T> GetCustomAttributes<T> (this MemberInfo element, bool inherit) where T : Attribute
171                 {
172                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T), inherit);
173                 }
174
175                 public static IEnumerable<T> GetCustomAttributes<T> (this Module element) where T : Attribute
176                 {
177                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
178                 }
179
180                 public static IEnumerable<T> GetCustomAttributes<T> (this ParameterInfo element) where T : Attribute
181                 {
182                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
183                 }
184
185                 public static IEnumerable<T> GetCustomAttributes<T> (this ParameterInfo element, bool inherit) where T : Attribute
186                 {
187                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T), inherit);
188                 }
189
190                 public static bool IsDefined (this Assembly element, Type attributeType)
191                 {
192                         return Attribute.IsDefined (element, attributeType);
193                 }
194
195                 public static bool IsDefined (this MemberInfo element, Type attributeType)
196                 {
197                         return Attribute.IsDefined (element, attributeType);
198                 }
199
200                 public static bool IsDefined (this Module element, Type attributeType)
201                 {
202                         return Attribute.IsDefined (element, attributeType);
203                 }
204
205                 public static bool IsDefined (this ParameterInfo element, Type attributeType)
206                 {
207                         return Attribute.IsDefined (element, attributeType);
208                 }
209
210                 public static bool IsDefined (this MemberInfo element, Type attributeType, bool inherit)
211                 {
212                         return Attribute.IsDefined (element, attributeType, inherit);
213                 }
214
215                 public static bool IsDefined (this ParameterInfo element, Type attributeType, bool inherit)
216                 {
217                         return Attribute.IsDefined (element, attributeType, inherit);
218                 }
219         }
220 }
221
222 #endif