Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
bbd0ea8c1This file is pinned to the selected release. Download the original to open it in your design tool.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Hast.Console.Extensions
{
public static class TypeExtensions
{
public static List<(Type Type, Attribute Attribute)> GetTypesWithAttribute(this Type attributeType) =>
AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(
assembly => assembly.GetTypes(),
(_, type) => (Type: type, Attribute: type?.GetCustomAttribute(attributeType, inherit: true)))
.Where(result => result.Type != null && result.Attribute != null)
.ToList();
}
}