mercredi 10 mai 2017

c# - Cast with GetType() and reflection

So after implemented Page Object Pattern using this tutorial i have several Pages that derived from BasePageElementMap.

And i want to handle some operation so i have this class:

public class DownloadAttachmentsHandler
    {
        public DownloadAttachmentsHandler(BasePageElementMap basePageElementMap)
        {
            Type type = basePageElementMap.GetType();            
        }
    }

Every Pages that derived from BasePageElementMap have this html elements that locate inside its class that derived from BasePageElementMap so in sace i am call this function like this:

UploadAttachmentsHandler att = new UploadAttachmentsHandler(new YahooEmailPage().Map);

I want to cast this into YahooEmailPage from my DownloadAttachmentsHandler method.

So currently i have this type object, how can i case it into YahooEmailPage ?





Aucun commentaire:

Enregistrer un commentaire