How to pass in repo item in method and access it's children : General Questions

How to pass in repo item in method and access it's children

Ask general questions here.

How to pass in repo item in method and access it's children

Postby pksy » Thu Jan 12, 2012 8:57 pm

Let's say my repository is structured as follows:

Main -> Summary -> Tab1
-> Tab2
-> Detail -> Report
-> Additional Info

Is there a way for me to pass in the "Main" repo item into a method as a parameter and within that method, be able to access the children of "Main" repo item? If this is possible, could somebody give me an example of what the method would look like sepcifically the parameter type?

void method(xxx repoItem)
{
repoItem.Summary.Tab1
repoItem.Detail.Report
}
pksy
 
Posts: 10
Joined: Fri Dec 16, 2011 8:06 pm

Re: How to pass in repo item in method and access it's children

Postby Support Team » Mon Jan 16, 2012 7:41 pm

Just have a look at the type of the "Main" repo item, it should be something like "MainAppFolder" or "MainFolder". The full type would be something like "YourRepositoryFolders.MainAppFolder" if your repository is called "YourRepository". You can then create a method like this:
void method(YourRepositoryFolders.MainAppFolder mainFolder)
{
    mainFolder.Summary.Tab1
    mainFolder.Detail.Report
}

However, I don't know your use case and, consequently, I don't know if that approach really suits your needs, because still you can only use that method for that very repository folder. It will not work for a folder that is "similar", e.g. has the same name and similar child repository items.
Besides, the type will always change if you rename your repository or the "Main" folder name.

Regards,
Alex
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: How to pass in repo item in method and access it's children

Postby pksy » Mon Jan 16, 2012 9:20 pm

Thanks! This is what I'm looking for. However, instead of using YourRepositoryFolders.MainAppFolder mainFolder, is there to be able to pass in any AppFolder so I can use the method for any folder in my repository?
pksy
 
Posts: 10
Joined: Fri Dec 16, 2011 8:06 pm

Re: How to pass in repo item in method and access it's children

Postby Support Team » Tue Jan 17, 2012 12:33 pm

pksy wrote:is there to be able to pass in any AppFolder so I can use the method for any folder in my repository?

As I already tried to explain in my previous post, this is not really possible, since Ranorex creates a specific type for each folder in the repository.
All folders inherit from the same base type (RepoGenBaseFolder), but if you use that type for your method parameter, you won't be able to access any items inside the folder within the method. The reason is again that for each folder a different class is created.

Regards,
Alex
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 1 guest