How to prepare VO for using methods from another library?

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to prepare VO for using methods from another library?

Post by ic2 »

This is a bit a follow up of this post:

https://www.xsharp.eu/forum/public-vo-v ... rary#13964
In short:

Most of our programs are a main program (often not more than a standard shell menu) and a few included libraries.

We have 1 AEF/library in VO which is basically our e-mail program. In this AEF, there are a few methods in 1 MEF from classes from our main library.

E.g.

Method ShowMail(param1,param2) CLASS SomeWindow
// Opens specific methods and windows from the email library

This method is called from the main library as follows: Send(#Showmail,param1,param2). This we need to do because in the library itself method ShowMail is not available.

This works fine in VO, but it does not when eventually we move to X#. .Net does not allow a method of class SomeWindow to reside in another prg than where the SomeWindow class is, otherwise you get external classes generated and everywhere error XS9016 .

What would be a recommended way to solve this in VO to make a future move to X# easy?

Dick
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to prepare VO for using methods from another library?

Post by Chris »

Hi Dick,

Usually the best way is to use a subclass. In your main app, define a CLASS ChildWindow INHERIT SomeWindow and define the method as part of this class. Then, when you create this window object, instead of using SomeWindow{}, use ChildWindow{} and do not change anything else. This should work without changes in both VO and X#.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to prepare VO for using methods from another library?

Post by ic2 »

Hello Chris,

That won't work I'd say because I can't create that method in my main app, as it uses classes from within the e-mail library, the 2nd lib. So I can't define it in the main app, and when I define it in the e-mail app with a different class name than I do now (=the inherited ChildWindow) then X# would still complain that it doesn't know class ChildWindow, as this is defined in the main app.

Even in VO this is not ideal. For example, I can't strong type a method email library when the class is defined in he main program. I don't see a real good solution for having some methods working on everything in library B when these methods belong to a class defined in library A. Probably the DELEGATE solution from your other reply is needed after all and in the end, even more elegant than the Send(# without any compiler checks and the necessity for non strong typed methods in the library B as required in VO.

Dick
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to prepare VO for using methods from another library?

Post by robert »

Dick,

In .Net you would solve this with interfaces, which VO does not have. That is one of the BIG advantages of X# over VO.
To solve this in VO you will have to use some kind of late binding.
I suggest you create a subclass for the window and create the window in your main app with CreateInstance(#ClassName) . This #ClassName could be stored in a variable that you can override from the library.

And then you call the methods on this object with Send, or you simply do not type the variable in which you store the window object and so the compiler will call the methods late bound.
Inside the library everything can be early bound of course.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to prepare VO for using methods from another library?

Post by ic2 »

Hello Robert,

Thank you for your suggestion. Although, as you know, I find only few advantages of .Net & .Net languages above VO I recognize that this could be solved better in .Net.
I try to prepare as much as possible in VO but for this I will have to do it differently in X#, with delegates or interfaces anyway, so I left the solution as it was (just a Send and not strong typing the called method).

Dick
Post Reply