Show thumbnail images in SWF.(Open,Save)FileDialog
[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
30 using System;
31 using System.Collections.Generic;
32
33 namespace System.Reflection
34 {
35         public static class CustomAttributeExtensions
36         {
37                 public static T GetCustomAttribute<T> (this Assembly element) where T : Attribute
38                 {
39                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
40                 }
41
42                 public static T GetCustomAttribute<T> (this MemberInfo element) where T : Attribute
43                 {
44                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
45                 }
46
47                 public static T GetCustomAttribute<T> (this Module element) where T : Attribute
48                 {
49                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
50                 }
51
52                 public static T GetCustomAttribute<T> (this ParameterInfo element) where T : Attribute
53                 {
54                         return (T) Attribute.GetCustomAttribute (element, typeof (T));
55                 }
56
57                 public static T GetCustomAttribute<T> (this MemberInfo element, bool inherit) where T : Attribute
58                 {
59                         return (T) Attribute.GetCustomAttribute (element, typeof (T), inherit);
60                 }
61
62                 public static T GetCustomAttribute<T> (this ParameterInfo element, bool inherit) where T : Attribute
63                 {
64                         return (T) Attribute.GetCustomAttribute (element, typeof (T), inherit);
65                 }
66
67                 public static Attribute GetCustomAttribute (this Assembly element, Type attributeType)
68                 {
69                         return Attribute.GetCustomAttribute (element, attributeType);
70                 }
71
72                 public static Attribute GetCustomAttribute (this MemberInfo element, Type attributeType)
73                 {
74                         return Attribute.GetCustomAttribute (element, attributeType);
75                 }
76
77                 public static Attribute GetCustomAttribute (this MemberInfo element, Type attributeType, bool inherit)
78                 {
79                         return Attribute.GetCustomAttribute (element, attributeType, inherit);
80                 }
81
82                 public static Attribute GetCustomAttribute (this Module element, Type attributeType)
83                 {
84                         return Attribute.GetCustomAttribute (element, attributeType);
85                 }
86
87                 public static Attribute GetCustomAttribute (this ParameterInfo element, Type attributeType)
88                 {
89                         return Attribute.GetCustomAttribute (element, attributeType);
90                 }
91
92                 public static Attribute GetCustomAttribute (this ParameterInfo element, Type attributeType, bool inherit)
93                 {
94                         return Attribute.GetCustomAttribute (element, attributeType, inherit);
95                 }
96
97                 public static IEnumerable<Attribute> GetCustomAttributes (this Assembly element)
98                 {
99                         return Attribute.GetCustomAttributes (element);
100                 }
101
102                 public static IEnumerable<Attribute> GetCustomAttributes (this Assembly element, Type attributeType)
103                 {
104                         return Attribute.GetCustomAttributes (element, attributeType);
105                 }
106
107                 public static IEnumerable<Attribute> GetCustomAttributes (this Module element)
108                 {
109                         return Attribute.GetCustomAttributes (element);
110                 }
111
112                 public static IEnumerable<Attribute> GetCustomAttributes (this Module element, Type attributeType)
113                 {
114                         return Attribute.GetCustomAttributes (element);
115                 }
116
117                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element)
118                 {
119                         return Attribute.GetCustomAttributes (element);
120                 }
121
122                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element, bool inherit)
123                 {
124                         return Attribute.GetCustomAttributes (element, inherit);
125                 }
126
127                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element, Type attributeType)
128                 {
129                         return Attribute.GetCustomAttributes (element, attributeType);
130                 }
131
132                 public static IEnumerable<Attribute> GetCustomAttributes (this ParameterInfo element, Type attributeType,
133                                                                           bool inherit)
134                 {
135                         return Attribute.GetCustomAttributes (element, attributeType, inherit);
136                 }
137
138                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element)
139                 {
140                         return Attribute.GetCustomAttributes (element);
141                 }
142
143                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element, bool inherit)
144                 {
145                         return Attribute.GetCustomAttributes (element, inherit);
146                 }
147
148                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element, Type attributeType)
149                 {
150                         return Attribute.GetCustomAttributes (element, attributeType);
151                 }
152
153                 public static IEnumerable<Attribute> GetCustomAttributes (this MemberInfo element, Type attributeType,
154                                                                           bool inherit)
155                 {
156                         return Attribute.GetCustomAttributes (element, attributeType, inherit);
157                 }
158
159                 public static IEnumerable<T> GetCustomAttributes<T> (this Assembly element) where T : Attribute
160                 {
161                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
162                 }
163
164                 public static IEnumerable<T> GetCustomAttributes<T> (this MemberInfo element) where T : Attribute
165                 {
166                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
167                 }
168
169                 public static IEnumerable<T> GetCustomAttributes<T> (this MemberInfo element, bool inherit) where T : Attribute
170                 {
171                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T), inherit);
172                 }
173
174                 public static IEnumerable<T> GetCustomAttributes<T> (this Module element) where T : Attribute
175                 {
176                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
177                 }
178
179                 public static IEnumerable<T> GetCustomAttributes<T> (this ParameterInfo element) where T : Attribute
180                 {
181                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T));
182                 }
183
184                 public static IEnumerable<T> GetCustomAttributes<T> (this ParameterInfo element, bool inherit) where T : Attribute
185                 {
186                         return (T[]) Attribute.GetCustomAttributes (element, typeof (T), inherit);
187                 }
188
189                 public static bool IsDefined (this Assembly element, Type attributeType)
190                 {
191                         return Attribute.IsDefined (element, attributeType);
192                 }
193
194                 public static bool IsDefined (this MemberInfo element, Type attributeType)
195                 {
196                         return Attribute.IsDefined (element, attributeType);
197                 }
198
199                 public static bool IsDefined (this Module element, Type attributeType)
200                 {
201                         return Attribute.IsDefined (element, attributeType);
202                 }
203
204                 public static bool IsDefined (this ParameterInfo element, Type attributeType)
205                 {
206                         return Attribute.IsDefined (element, attributeType);
207                 }
208
209                 public static bool IsDefined (this MemberInfo element, Type attributeType, bool inherit)
210                 {
211                         return Attribute.IsDefined (element, attributeType, inherit);
212                 }
213
214                 public static bool IsDefined (this ParameterInfo element, Type attributeType, bool inherit)
215                 {
216                         return Attribute.IsDefined (element, attributeType, inherit);
217                 }
218         }
219 }
220