Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CustomAttributeExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Reflection;
7 
8 namespace SiliconStudio.Core.Reflection
9 {
10  public static class CustomAttributeExtensions
11  {
12  public static T GetCustomAttributeEx<T>(this Assembly assembly) where T : Attribute
13  {
14  return (T)GetCustomAttributeEx(assembly, typeof(T));
15  }
16 
17  public static Attribute GetCustomAttributeEx(this Assembly assembly, Type attributeType)
18  {
19 #if SILICONSTUDIO_PLATFORM_MONO_MOBILE
20  return Attribute.GetCustomAttribute(assembly, attributeType);
21 #else
22  return assembly.GetCustomAttribute(attributeType);
23 #endif
24  }
25 
26  public static IEnumerable<Attribute> GetCustomAttributesEx(this Assembly assembly, Type attributeType)
27  {
28 #if SILICONSTUDIO_PLATFORM_MONO_MOBILE
29  return Attribute.GetCustomAttributes(assembly, attributeType);
30 #else
31  return assembly.GetCustomAttributes(attributeType);
32 #endif
33  }
34 
35  public static IEnumerable<T> GetCustomAttributesEx<T>(this Assembly assembly) where T : Attribute
36  {
37  return GetCustomAttributesEx(assembly, typeof(T)).Cast<T>();
38  }
39  }
40 }
static Attribute GetCustomAttributeEx(this Assembly assembly, Type attributeType)
static IEnumerable< Attribute > GetCustomAttributesEx(this Assembly assembly, Type attributeType)