// Copyright © 2017-2018 Atomic Software, LLC. All Rights Reserved. // See LICENSE.md for full license information. using Atom.Core.Collections; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace Atom.Core { public static class AtomAssembly { /// /// Represents the assembly's name. /// public static string Name = Assembly.GetEntryAssembly().GetName().Name; /// /// Represents the assembly's version. /// public static string Version = 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 { return 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 Pair(Attribute, Method); } } }