From be21ddb38ef3f8a09a18b8614b803a1f79132435 Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Wed, 9 Oct 2019 10:20:10 +0200 Subject: [PATCH] Added GetAssemblyAttributes to TypeLoader --- src/Umbraco.Core/Composing/TypeLoader.cs | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Umbraco.Core/Composing/TypeLoader.cs b/src/Umbraco.Core/Composing/TypeLoader.cs index fe7a561eca..1a5cd6751f 100644 --- a/src/Umbraco.Core/Composing/TypeLoader.cs +++ b/src/Umbraco.Core/Composing/TypeLoader.cs @@ -505,6 +505,38 @@ namespace Umbraco.Core.Composing #endregion + #region Get Assembly Attributes + + /// + /// Gets the assembly attributes. + /// + /// The attribute type. + /// + /// The assembly attributes of the specified type. + /// + public IEnumerable GetAssemblyAttributes() + where T : Attribute + { + return AssembliesToScan.SelectMany(a => a.GetCustomAttributes()); + } + + /// + /// Gets the assembly attributes. + /// + /// The attribute types. + /// + /// The assembly attributes of the specified types. + /// + /// attributeTypes + public IEnumerable GetAssemblyAttributes(params Type[] attributeTypes) + { + if (attributeTypes == null) throw new ArgumentNullException(nameof(attributeTypes)); + + return AssembliesToScan.SelectMany(a => attributeTypes.SelectMany(at => a.GetCustomAttributes(at))).ToList(); + } + + #endregion + #region Get Types ///