Page 1 of 1

How to generalize the repository content

Posted: Wed Oct 21, 2015 11:37 am
by subodh4u7
Hi,

I have once scenario where I want to pass parameter as below
Call Method(repo.organizer);

Call Method1(repo.Start)

Method(RepoScanConsoleFolders.OrganizerViewFolder seg1)
{
// some peice of code
}

Method1(RepoScanConsoleFolders.StartFolder seg2)
{
// some peice of code
}

I want to generalize the called method so that i can pass any repository type data rather calling method(), method1() separately.

Can you please help me out.

Re: How to generalize the repository content

Posted: Wed Oct 21, 2015 6:46 pm
by tvu
I don't know the best approach to this, but what I have been doing is to pass in the RepoItemInfo and creating an adapter from it. From there, you will interact with the adapter.

Code: Select all

Method(Ranorex.Core.Repository.RepoItemInfo myRepoItemInfo)
{
    Ranorex.Adapter myAdapter;

    if (myRepoItemInfo.Exist())
        myAdapter = myRepoItemInfo.CreateAdapter<Ranorex.Adapter>();
    else
        return someErrorState;

    // code to do something with myAdapter
}
Hope this helps.