// Copyright 2018 RED Software, LLC. All Rights Reserved. using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace IgniteEngine { /// /// Class to interact with the assembly. /// public static class Assembly { /// /// Represents the assembly's name. /// public static string Name = System.Reflection.Assembly.GetEntryAssembly().GetName().Name; /// /// Represents the assembly's version. /// public static string Version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(3); /// /// Find all methods in the assembly with the specified attribute. /// /// The type of the attribute being searched for. /// A list of all methods with the specified attribute. public static IEnumerable> GetMethodsWithAttribute() where TAttribute : Attribute => from Method in AppDomain.CurrentDomain.GetAssemblies() .Where(assembly => !assembly.GlobalAssemblyCache) .SelectMany(assembly => assembly.GetTypes()) .SelectMany(type => type.GetMethods()) let Attribute = Attribute.GetCustomAttribute(Method, typeof(TAttribute), false) as TAttribute where Attribute != null select new Tuple(Attribute, Method); } }