Author:水如烟
Namespace
LzmTW.uSystem.uWindows.AddIns
Public Interface IPackage
Sub Load( ByVal mainform As Windows.Forms.Form)
Sub Unload()
End Interface
End Namespace
Public Interface IPackage
Sub Load( ByVal mainform As Windows.Forms.Form)
Sub Unload()
End Interface
End Namespace
Namespace
LzmTW.uSystem.uWindows.AddIns
< Serializable() > _
Public Class AddInsItem
Private gName As String
Private gLocation As String
Private gIsLoad As Boolean
Sub New ()
End Sub
Sub New ( ByVal name As String , ByVal location As String )
gName = name
gLocation = location
gIsLoad = False
End Sub
Public Property Name() As String
Get
Return gName
End Get
Set ( ByVal value As String )
gName = value
End Set
End Property
Public Property Location() As String
Get
Return gLocation
End Get
Set ( ByVal value As String )
gLocation = value
End Set
End Property
Public Property IsLoad() As Boolean
Get
Return gIsLoad
End Get
Set ( ByVal value As Boolean )
gIsLoad = value
End Set
End Property
End Class
End Namespace
< Serializable() > _
Public Class AddInsItem
Private gName As String
Private gLocation As String
Private gIsLoad As Boolean
Sub New ()
End Sub
Sub New ( ByVal name As String , ByVal location As String )
gName = name
gLocation = location
gIsLoad = False
End Sub
Public Property Name() As String
Get
Return gName
End Get
Set ( ByVal value As String )
gName = value
End Set
End Property
Public Property Location() As String
Get
Return gLocation
End Get
Set ( ByVal value As String )
gLocation = value
End Set
End Property
Public Property IsLoad() As Boolean
Get
Return gIsLoad
End Get
Set ( ByVal value As Boolean )
gIsLoad = value
End Set
End Property
End Class
End Namespace
Namespace
LzmTW.uSystem.uWindows.AddIns
Public Class AddInsConfig
Inherits LzmTW.ConfigManger( Of AddInsItem)
Public Function FindItem( ByVal name As String ) As AddInsItem
Return MyBase .Find( " Name " , name)
End Function
End Class
End Namespace
Public Class AddInsConfig
Inherits LzmTW.ConfigManger( Of AddInsItem)
Public Function FindItem( ByVal name As String ) As AddInsItem
Return MyBase .Find( " Name " , name)
End Function
End Class
End Namespace
Namespace
LzmTW.uSystem.uWindows.AddIns
< AttributeUsage(AttributeTargets.Class) > _
Public Class AddInsAttribute
Inherits Attribute
Private gName As String
Private gFullTypeName As String
Private gAuthor As String
Private gVersion As String
Private gDescription As String
Private gLastTime As String
Sub New ( ByVal name As String , ByVal fulltypename As String )
gName = name
gFullTypeName = fulltypename
End Sub
Public ReadOnly Property Name() As String
Get
Return gName
End Get
End Property
Public ReadOnly Property FullTypeName() As String
Get
Return gFullTypeName
End Get
End Property
Public Property Author() As String
Get
Return gAuthor
End Get
Set ( ByVal value As String )
gAuthor = value
End Set
End Property
Public Property Version() As String
Get
Return gVersion
End Get
Set ( ByVal value As String )
gVersion = value
End Set
End Property
Public Property Description() As String
Get
Return gDescription
End Get
Set ( ByVal value As String )
gDescription = value
End Set
End Property
Public Property LastTime() As String
Get
Return gLastTime
End Get
Set ( ByVal value As String )
gLastTime = value
End Set
End Property
Public Shadows Function ToString() As String
Dim b As New System.Text.StringBuilder
b.AppendFormat( " 作者:{0} " , Author)
b.Append(vbCrLf)
b.AppendFormat( " 描述:{0} " , Description)
b.Append(vbCrLf)
b.AppendFormat( " 版本:{0} " , Version)
b.Append(vbCrLf)
b.AppendFormat( " 最后更新日期:{0} " , LastTime)
Return b.ToString
End Function
End Class
End Namespace
< AttributeUsage(AttributeTargets.Class) > _
Public Class AddInsAttribute
Inherits Attribute
Private gName As String
Private gFullTypeName As String
Private gAuthor As String
Private gVersion As String
Private gDescription As String
Private gLastTime As String
Sub New ( ByVal name As String , ByVal fulltypename As String )
gName = name
gFullTypeName = fulltypename
End Sub
Public ReadOnly Property Name() As String
Get
Return gName
End Get
End Property
Public ReadOnly Property FullTypeName() As String
Get
Return gFullTypeName
End Get
End Property
Public Property Author() As String
Get
Return gAuthor
End Get
Set ( ByVal value As String )
gAuthor = value
End Set
End Property
Public Property Version() As String
Get
Return gVersion
End Get
Set ( ByVal value As String )
gVersion = value
End Set
End Property
Public Property Description() As String
Get
Return gDescription
End Get
Set ( ByVal value As String )
gDescription = value
End Set
End Property
Public Property LastTime() As String
Get
Return gLastTime
End Get
Set ( ByVal value As String )
gLastTime = value
End Set
End Property
Public Shadows Function ToString() As String
Dim b As New System.Text.StringBuilder
b.AppendFormat( " 作者:{0} " , Author)
b.Append(vbCrLf)
b.AppendFormat( " 描述:{0} " , Description)
b.Append(vbCrLf)
b.AppendFormat( " 版本:{0} " , Version)
b.Append(vbCrLf)
b.AppendFormat( " 最后更新日期:{0} " , LastTime)
Return b.ToString
End Function
End Class
End Namespace
Imports
System.Reflection
Imports System.Windows.Forms
Namespace LzmTW.uSystem.uWindows.AddIns
Friend Class AddInsAssemblyReader
Public Shared Function Read( ByVal file As String , ByVal name As String ) As AddInsAttribute
Dim myAttributes As AddInsAttribute() = Read(file)
For Each myAttribute As AddInsAttribute In myAttributes
If myAttribute.Name.Equals(name) Then
Return myAttribute
End If
Next
Return Nothing
End Function
Public Shared Function Read( ByVal file As String ) As AddInsAttribute()
Dim mResult( - 1 ) As AddInsAttribute
Dim mAssembly As Assembly = Assembly .LoadFrom(file)
For Each t As Type In mAssembly.GetTypes
For Each a As Object In t.GetCustomAttributes( False )
If TypeOf a Is AddInsAttribute Then
uCollection.CommonFunction.Append( Of AddInsAttribute)(mResult, CType (a, AddInsAttribute))
End If
Next
Next
Return mResult
End Function
End Class
End Namespace
Imports System.Windows.Forms
Namespace LzmTW.uSystem.uWindows.AddIns
Friend Class AddInsAssemblyReader
Public Shared Function Read( ByVal file As String , ByVal name As String ) As AddInsAttribute
Dim myAttributes As AddInsAttribute() = Read(file)
For Each myAttribute As AddInsAttribute In myAttributes
If myAttribute.Name.Equals(name) Then
Return myAttribute
End If
Next
Return Nothing
End Function
Public Shared Function Read( ByVal file As String ) As AddInsAttribute()
Dim mResult( - 1 ) As AddInsAttribute
Dim mAssembly As Assembly = Assembly .LoadFrom(file)
For Each t As Type In mAssembly.GetTypes
For Each a As Object In t.GetCustomAttributes( False )
If TypeOf a Is AddInsAttribute Then
uCollection.CommonFunction.Append( Of AddInsAttribute)(mResult, CType (a, AddInsAttribute))
End If
Next
Next
Return mResult
End Function
End Class
End Namespace