I am creating an object of the logger type dynamically, trying to use the concept of Reflection. My code is as follows.
public static ILogger Create(string loggerType)
{
ILogger logger = null;
string loggerValue = WebConfigurationManager.AppSettings.Get(loggerType);
string[] loggerDll = loggerValue.Split(',');
string[] loggerTypeValue = loggerDll[0].Split('.');
Assembly asm = Assembly.Load(loggerTypeValue[0]);
Type type = asm.GetType(loggerDll[1]);
logger = (ILogger)Activator.CreateInstance(type);
return logger;
}
I want to drop the use of Activator.CreateInstance() method. What is the alternative choice for me?