Come creare e leggere degli attributi Extra nel file AssemblyInfo.cs
ExtraAssemblyInfoAttribute.vb
Namespace Morpheusweb.Utils
<AttributeUsage(AttributeTargets.Assembly, AllowMultiple := True)> _
Public NotInheritable Class ExtraAssemblyInfoAttribute
Inherits Attribute
Public Sub New(ExtraAssemblyInfo As String)
_ExtraAssemblyInfo = ExtraAssemblyInfo
End Sub
Public ReadOnly Property ExtraAssemblyInfo() As String
Get
Return _ExtraAssemblyInfo
End Get
End Property
Private _ExtraAssemblyInfo As String
End Class
End Namespace
Public Shared Function GetExtraAssemblyInfo(AssemblyName As String) As List(Of String)
Dim info As New List(Of String)()
Dim t As Type = Nothing
Dim a As Assembly = If(String.IsNullOrEmpty(AssemblyName), Assembly.GetEntryAssembly(), Assembly.LoadFile(AssemblyName))
If a IsNot Nothing Then
t = a.EntryPoint.ReflectedType
End If
If t IsNot Nothing Then
Dim attr As Object() = t.[Module].Assembly.GetCustomAttributes(GetType(ExtraAssemblyInfoAttribute), False)
If (attr.Length > 0) Then
For i As Integer = 0 To attr.Length - 1
info.Add(DirectCast(attr(i), ExtraAssemblyInfoAttribute).ExtraAssemblyInfo)
Next
End If
End If
Return info
End Function