Having following class structure, how can I get instance of Configuration<X>
where class X
is not known at the build time?
Initial setup:
public interface IConfiguration
{
}
public class Configuration<T> : IConfiguration
{
}
List<IConfiguration> configList;
configList.Add( new Configuration<X>());
configList.Add( new Configuration<Y>());
configList.Add( new Configuration<Z>());
Foreach(var config in configList)
{
Proccess(config) // errors . I need to cast in here
}
Proccess<T>(Configuration<T>) {}
Boxing or reflection is allowed. I need to cast base class to unknown generic type class.