如何在另一个DLL中覆盖/扩展一对类(list(of< element>),< element>)? [英] How to override/extend a pair of class (list(of <element>), <element>) in another DLL ?
问题描述
嗨。
我正在使用vb.net而我正在尝试扩展和/或覆盖来自引用DLL(称为IFCX)的类使用DLL(ESTX)。
整个问我为什么这样做?这个原因是overwellmind:
- 这两个DLL都有一个方法,但是当我使用ESTX时,我也从IFCX加载数据,但是IFCX对象应该回答与ESTX相关的嵌套值。
- 创建IFCX时,不会认为ESTX会存在。因此没有理由在同一个DLL中加入它。
- IFCX提供了一个类(作为IFCXItem的列表),我知道我们可以继承对象,但如果我重写IFCXitem, list不再打字,并且继承列表意味着什么,因为我需要它作为类型列表,所以源和最终使用列表之间的连接将是一团糟。
所以我正在寻找一个带有2个项目的样本,在visualstudio下有2个类(类型为class + class(of typedclass)在第一个,exented或部分类的typedclass在另一个。
精度#1:我没有将它们包含在根命名空间下,所以我猜根有自己的DLL名称。
我尝试了什么:
在ESTX项目中我试着写这个:
Hi.
I'm using vb.net and I'm trying to extend and/or overrides a class from a referencing DLL (called IFCX) in the using DLL (ESTX).
Whole shoud asking me "WHY doing this ?" the reason is overwellmind :
- Both DLL have a means, but when i use ESTX, i load the data from IFCX too, but IFCX object should answers to nested values in relation with ESTX.
- When IFCX was created, it did not espect ESTX will exist. So there is no reason to join this in a same DLL.
- IFCX provide a class (as list(of IFCXItem)), I know that we can inherits objects, but if i overrides IFCXitem, the list is not longer well typed, and inherits the list means nothing, because i need it as typed list, so the connection between the source and the final using list will be a mess.
So i'm looking for a sample with 2 projects under visualstudio, with 2 class (typed class + list(of typedclass) in first, exented or partial class of typedclass in the other.
Precision #1 : I did not included them under a root namespace, so i guess there root are there own DLL name.
What I have tried:
in ESTX project i tryed to write this :
Namespace Global
Namespace IFCX
Partial class MyIFCXClass
Public overridable readonly Property Image as System.drawwing.image
Get
'...
return '...
End Get
End Class
End Namespace
End Namespace
但它似乎不起作用。
But it seems it doesn't work.
Imports System.Runtime.CompilerServices
Module MyClassExtended
<Extension()> _
Public Function Assignations(Sender as IFCX.IMPORT_ELEMENT,about as ESTX.BL_ESTX) as list(of ESTX.ASSIGNATION)
dim _list as list(of ESTX.ASSIGNATION)
'can't raise specific event Ask_Assignations because Ask_Assignations should not exist in IFCX metadata
'can't rais generic event Ask(args), because not in the class !
'can call OnAsk() who is doing Raisevent Ask(args) but weird !
_list = about.Assignations.where(function(w) w.ID_IMPORTELEMENT = Sender.ID).tolist
return _list
end function
End Module
Partial class BL_ESTX
'Local Variable
private _My_IMPORT_ELEMENTS as IFCX.IMPORT_ELEMENTS
'IFCX endloading event help ESTX to catch it
Private sub IFCX_EndLoading(Sender as object) handles _BL_IFCX.EndLoading
_My_IMPORT_ELEMENTS = ctype(sender, BL_IFCX).My_Import_ELEMENTS
end sub
'a property to acces it ...
public readonly Property My_Imports_Elements as IFCX.IMPORT_ELEMENTS
get
return _My_IMPORT_ELEMENTS
end get
end property
' a kind of use
Public sub NoAssignationReport()
My_Imports_Elements.foreach(sub(x) if x.Assignations(me).count = 0 then debug.print(x.Name))
End sub
End class
这篇关于如何在另一个DLL中覆盖/扩展一对类(list(of< element>),< element>)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!