public ConfigurationProviderFactory(ILogger logger) { var config = ConfigurationManager.GetSection("commerceApp") as CommerceAppConfigurationSection; if (config?.PaymentProcessor.Type != null && config.CustomerNotifier.Type != null) { _paymentProcessor = Activator.CreateInstance(Type.GetType(config.PaymentProcessor.Type)) as IPaymentProcessor; _customerNotifier = Activator.CreateInstance(Type.GetType(config.CustomerNotifier.Type)) as ICustomerNotifier; if (_customerNotifier != null) { _customerNotifier.FromAddress = config.CustomerNotifier.FromAddress; _customerNotifier.SmtpServer = config.CustomerNotifier.SmtpServer; } _events = new CommerceAppExtensionPoints(); foreach (CommerceAppModuleElement element in config.Modules) { ICommerceModule module = Activator.CreateInstance(Type.GetType(element.Type)) as ICommerceModule; module.Initialize(_events); } } else { logger.Log("Incorrect configurations in App.config."); } }
public ConfigurationFactory() { CommerceEngineConfigurationSection config = ConfigurationManager.GetSection("commerceEngine") as CommerceEngineConfigurationSection; if (config != null) { IPaymentProcessor paymentProcessor = Activator.CreateInstance(Type.GetType(config.PaymentProcessor.Type)) as IPaymentProcessor; IMailer mailer = Activator.CreateInstance(Type.GetType(config.Mailer.Type)) as IMailer; mailer.FromAddress = config.Mailer.FromAddress; mailer.SmtpServer = config.Mailer.SmtpServer; _PaymentProcessor = paymentProcessor; _Mailer = mailer; // initialize modules _Events = new CommerceEvents(); foreach (ProviderSettings moduleElement in config.Modules) { ICommerceModule module = Activator.CreateInstance(Type.GetType(moduleElement.Type)) as ICommerceModule; module.Initialize(_Events, moduleElement.Parameters); } } }