DBServer Init/Constructor anpassen

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

DBServer Init/Constructor anpassen

Post by Horst »

Hallo Leute
Bei Cavo gabs die RDD Classes SDK und da konnte man nachschauen was z.B. METHOD Init( oFile, lShareMode, lReadOnlyMode, xDriver, aRdd ) CLASS DbServer macht und evt. in einer eigenen Klasse anpassen.
Wollte das auch bei X# machen, mal reinschauen und evt. erweitern. Finde aber keine Methode wie die Init() von Cavo und die Constructor Methode ist da ziemmlich klein.
Wo finde ich das ?
Ich war auf - https://github.com/X-Sharp/XSharpPublic ... bf/DBF.prg
Gruss
Horst
User avatar
wriedmann
Posts: 3645
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DBServer Init/Constructor anpassen

Post by wriedmann »

Hallo Horst,
das, was Du da anschaust, hast Du bei VO nie gesehen, denn das sind die Quellen des RDDs selber.
Und da durchzublicken, wird schon schwierig.
Ich habe mich eine Weile damit befasst, weil ich eine eigene Server-Klasse gebaut habe, die auf den RDD-Klassen aufsetzt.
Was Du hier siehst, ist eine ganze Hierarchie von Klassen und Interfaces, die aufeinander aufsetzen, und die leider nicht dokumentiert sind - wäre auch so ein Punkt auf meiner Liste, der nie erledigt werden wird.
Wenn Dich der Code der DBServer-Klassen interessiert, musst Du woanders nachschauen - das ist aber der identische Code, wie Du ihn in VO findest.
lg
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

DBServer Init/Constructor anpassen

Post by Horst »

Hallo Wolfgang
Habe jetzt weiter gesucht und bin nun hier fündig geworden.
https://github.com/X-Sharp/XSharpPublic ... Server.prg

Danke
User avatar
wriedmann
Posts: 3645
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DBServer Init/Constructor anpassen

Post by wriedmann »

Hallo Horst,
ja, genau, das sind die Quellen für den VO-DBServer.
Das andere ist das RDD selber.
lg
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

DBServer Init/Constructor anpassen

Post by Horst »

Hallo Wolfgang
Die original Constructor Methode ruft Super() auf , gemeint ist da der Constructor von DataServer (denke ich). Wen ich das einfach mache ruft er doch die Contructor Methode von DBServer auf. Oder ? Das will ich ja nicht. Wie komme ich auf die Constructor Methode von DataServer ?
Gruss
Horst
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

DBServer Init/Constructor anpassen

Post by robert »

Hort,
If I understand you correctly you want to skip the constructor in the parent class and call the constructor of the grandparent directly.
That is not allowed in .Net.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

DBServer Init/Constructor anpassen

Post by Horst »

Hello Robert
I wanna replace the Constructor Method of DBServer with my one.

I only change some code

nCnt := 10 // X Versuche HK
DO WHILE nCnt > 0
lRetCode := VoDbUseArea( FALSE, rddList, oFileSpec:FullPath, Symbol2String( symAlias ), ;
lShared, lReadOnly )
IF ! lRetCode
nCnt --
dTicker := Seconds ()
DO WHILE TRUE
IF Seconds () - dTicker > 1.0
EXIT
ENDIF
ENDDO
ENDIF
ENDDO

And now i am not sure what Method my Super () is calling.
The Super() of DBServer or the Super() of DateServer.

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

DBServer Init/Constructor anpassen

Post by robert »

Horst,
Replacing a constructor is NOT possible. The .Net framework does not allow that.
You can create a subclass and write a constructor in the subclass, but eventually you will have to call SUPER() somewhere. If you don't do that then the compiler will insert a call to SUPER().
You could consider to open the file and then call SUPER() without parameters. This will however generate an error inside the DbServer constructor and the RECOVER USING clause inside the DbServer constructor the area will be closed again. If you really want to replace the constructor then you will have to create your own version of the DbServer class, copy the existing code and adjust the constructor.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

DBServer Init/Constructor anpassen

Post by Chris »

There's a trick that you can use in the VO dialect:

- Copy ALL the code of the DBServer constructor() from https://github.com/X-Sharp/XSharpPublic ... Server.prg to the constructor of your own class.

- Replace the SUPER() call in the beginning of it with:

Code: Select all

IF FALSE
  SUPER() // trick the compiler into thinking that you are calling the parent constructor
ENDIF
SELF:aClients := { } // this is the only command in the DataServer constructor
This trick will make the compiler emit code that does not call ANY of the parent constructors at all. But because in this case the DataServer constructor only has one line of code, it is easy to use this trick.

Robert please do not disable this dirty hack, I had needed to use this in other projects as well :)
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

DBServer Init/Constructor anpassen

Post by robert »

Chris,
You naughty boy !

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply