mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Add version-independent helper for retrieving assembly attributes
This commit is contained in:
1 parent
cfa6857bb0
commit
28671ceb6f
2 files changed
+13
-3
No files matched your search
@@ -2,8 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Core;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace BepInEx
|
||||
@@ -269,6 +269,17 @@ namespace BepInEx
|
||||
return (T[])pluginType.GetCustomAttributes(typeof(T), true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified attributes of an assembly, if they exist.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly.</param>
|
||||
/// <typeparam name="T">The attribute type to retrieve.</typeparam>
|
||||
/// <returns>The attributes of the type, if existing.</returns>
|
||||
public static T[] GetAttributes<T>(Assembly assembly) where T : Attribute
|
||||
{
|
||||
return (T[])assembly.GetCustomAttributes(typeof(T), true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified attributes of an instance, if they exist.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user