Dynamic casting using a generic interface
        Posted  
        
            by Phil Whittaker
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Phil Whittaker
        
        
        
        Published on 2010-05-27T13:45:44Z
        Indexed on 
            2010/05/27
            13:51 UTC
        
        
        Read the original article
        Hit count: 306
        
Hi
Is there any way to cast to a dynamic generic interface..
Site s = new Site();
IRepository<Site> obj = (IRepository<s.GetType()>)ServiceLocator.Current.GetInstance(t)
obviously the above won't compile with this cast. Is there anyway to do a dynamic cast of a generic interface. I have tried adding a non generic interface but the system is looses objects in the Loc container.
Thanks
Phil
© Stack Overflow or respective owner