File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Linq ;
3+ using System . Reflection ;
4+
5+ namespace Oxide
6+ {
7+ public static class ExtensionMethods
8+ {
9+ #region Metadata
10+
11+ /// <summary>
12+ /// Gets all <see cref="AssemblyMetadataAttribute"/> from a assembly
13+ /// </summary>
14+ /// <param name="assembly">The assembly to query for metadata</param>
15+ /// <returns>Array of metadata</returns>
16+ public static AssemblyMetadataAttribute [ ] Metadata ( this Assembly assembly )
17+ {
18+ return Attribute . GetCustomAttributes ( assembly , typeof ( AssemblyMetadataAttribute ) , false ) as AssemblyMetadataAttribute [ ] ;
19+ }
20+
21+ /// <summary>
22+ /// Gets values of all <see cref="AssemblyMetadataAttribute"/> filtered by key
23+ /// </summary>
24+ /// <param name="assembly">The assembly to query for metadata</param>
25+ /// <param name="key">The metadata key to filter by</param>
26+ /// <returns>Array of metadata values</returns>
27+ public static string [ ] Metadata ( this Assembly assembly , string key )
28+ {
29+ return assembly . Metadata ( ) . Where ( meta => meta . Key . Equals ( key , StringComparison . InvariantCultureIgnoreCase ) ) . Select ( meta => meta . Value ) . ToArray ( ) ;
30+ }
31+
32+ #endregion
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments