Page 1 of 1

Define variable for rooted folder

Posted: Thu Jan 28, 2016 8:59 pm
by jackrabbit
In my user code, I need to access a bunch of objects from the same rooted folder. Of cours, I can type:

Code: Select all

facture.SetFactureDiverseValues
(
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtDateEcheance.TextValue,
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtMontantDepot.TextValue,
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtNoDepot.TextValue,
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtReference.TextValue,
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtTotalAvantTaxe.TextValue,
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtTotalTPS.TextValue,
  repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses.TxtTotalTVQ.TextValue
);
As a shorcut, I decided to make this shorter with new code:

Code: Select all

var Histo = repo.Ruban.Scroller.HistoriqueFactures.HistoriqueFacturesDiverses;

facture.SetFactureDiverseValues
(
  Histo.TxtDateEcheance.TextValue,
  Histo.TxtMontantDepot.TextValue,
  Histo.TxtNoDepot.TextValue,
  Histo.TxtReference.TextValue,
  Histo.TxtTotalAvantTaxe.TextValue,
  Histo.TxtTotalTPS.TextValue,
  Histo.TxtTotalTVQ.TextValue
);

However, I always try to stay away from generic VAR definitions like "var Histo", I prefer to fully qualify every variable.  I could not find the specific definition for my Rooted Folder element that contains my objects.

I tried to find one in the Ranorex.XXX definitions, without success, is there a Rooted Folder variable type?


Re: Define variable for rooted folder

Posted: Thu Jan 28, 2016 9:24 pm
by krstcs
Each rooted folder is it's own class, but they are all derived from RepoGenBaseFolder, which is abstract, so you can't instantiate it specifically, but you can use it as a type for passing generic folders around since they are all derived from it.

http://www.ranorex.com/Documentation/Ranorex/

Look under "Ranorex.Core.Repository namespace" tree item...