public MyWorkerService( IPersitenceServiceConfigDependent persitenceServiceConfigDependent, IConnectionStrings connectionStrings, IAzureServiceConfiguration azureServiceConfiguration, IMicrosoftStorageConfig microsoftStorageConfig, IAppConfigSettings appConfigSettings) { _connectionStrings = connectionStrings; _azureServiceConfiguration = azureServiceConfiguration; _microsoftStorageConfig = microsoftStorageConfig; _persitenceServiceConfigDependent = persitenceServiceConfigDependent; _appConfigSettings = appConfigSettings; }
public MyWorkerService( IPersitenceServiceConfigDependent persitenceServiceConfigDependent, IConnectionStrings connectionStrings, IAzureServiceConfiguration azureServiceConfiguration, IMicrosoftStorageConfig microsoftStorageConfig, IAppConfigSettings appConfigSettings) { _connectionStrings = connectionStrings; _azureServiceConfiguration = azureServiceConfiguration; _microsoftStorageConfig = microsoftStorageConfig; _persitenceServiceConfigDependent = persitenceServiceConfigDependent; _appConfigSettings = appConfigSettings; }
private IAzureServiceConfiguration ComplementConfigurationFromConfigurationManager(IAzureServiceConfiguration config) { Trace.WriteLine("Complementing configuration"); var azureConfigType = config.GetType(); foreach(PropertyInfo property in config.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)) { var xmlConfigValue = CloudConfigurationManager.GetSetting(property.Name); var liveConfigPropValue = (string)azureConfigType.GetProperty(property.Name).GetValue(config, null); if(string.IsNullOrEmpty(liveConfigPropValue)) { Trace.WriteLine(property.Name + " in live config is empty. Complementing with '" + xmlConfigValue + "' from ConfigurationManager."); property.SetValue(config, xmlConfigValue); } // do something with the property } return config; }