Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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 :
VB
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.
Posted
Updated 26-Apr-18 5:11am
Comments
Maciej Los 26-Apr-18 7:49am    
Interesting problem...

Are you an author of both dll's? Do you have source codes? If yes, why not to create another version of IFCX dll?
Frederic GIRARDIN 26-Apr-18 8:37am    
Yes, I am the author of both DLLs. Each DLL represents a file extension; which means that each contains the treatment modalities proper to its content.
An ESTX file can have a reference to IFCX content. IFCX objects are custom objects that represent the extraction of an IFC file. A kind of alternative data format. These objects have an IFCX-compliant meaning, but once an ESTX references an IFCX file, it becomes its objects. The only solution I have found for the moment disappoints me! Create both a new class of <inherited element> from IFCX.element class to add functionality to my objects, but also a new class list <inherited elements>. I am therefore forced to monitor the changes in the IFCX list to reproduce them in ESTX. It's heavy and I'm convinced that there is another way to go about it ...
Richard Deeming 26-Apr-18 11:09am    
Why do you need to create a new list? A List<BaseClass> can happily contain instances of DerivedClass without breaking anything.
Frederic GIRARDIN 26-Apr-18 12:03pm    
may you can give more detail or a sample ?
Richard Deeming 26-Apr-18 12:04pm    
class BaseClass { }
class DerivedClass : BaseClass { }

List<BaseClass> theList = new List<BaseClass>();
theList.Add(new BaseClass());
theList.Add(new DerivedClass());

1 solution

VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900