LzmTW.uSystem.uWindows.AddIns

Author:水如烟   

Namespace  LzmTW.uSystem.uWindows.AddIns
    
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

 

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

 

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

 

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值