public void Initialise(BaseDto configuration, DictionaryParameters parameters) { Contract.Assert(configuration is ScheduledJobsWorkerConfiguration); parameters = parameters ?? new DictionaryParameters(); var cfg = configuration as ScheduledJobsWorkerConfiguration; // get communication update and retry variables cfg.UpdateIntervalInMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["UpdateIntervalMinutes"]); cfg.UpdateIntervalInMinutes = (0 != cfg.UpdateIntervalInMinutes) ? cfg.UpdateIntervalInMinutes : ScheduledJobsWorkerConfiguration.UPDATE_INTERVAL_IN_MINUTES_DEFAULT; cfg.ServerNotReachableRetries = Convert.ToInt32(ConfigurationManager.AppSettings["ServerNotReachableRetries"]); cfg.ServerNotReachableRetries = cfg.UpdateIntervalInMinutes * (0 != cfg.ServerNotReachableRetries ? cfg.ServerNotReachableRetries : ScheduledJobsWorkerConfiguration.SERVER_NOT_REACHABLE_RETRIES_DEFAULT); // apply parameters if overridden on command line var uri = ConfigurationManager.AppSettings["Uri"]; if(parameters.ContainsKey("args0")) { uri = parameters["args0"] as string; } Contract.Assert(!string.IsNullOrWhiteSpace(uri)); cfg.Uri = new Uri(uri); cfg.ManagementUriName = ConfigurationManager.AppSettings["ManagementUri"]; if(parameters.ContainsKey("args1")) { cfg.ManagementUriName = parameters["args1"] as string; } Contract.Assert(!string.IsNullOrWhiteSpace(cfg.ManagementUriName)); // load plugins var configurationLoader = new PluginLoaderConfigurationFromAppSettingsLoader(); var pluginLoader = new PluginLoader(configurationLoader, cfg.Logger); cfg.Plugins = pluginLoader.InitialiseAndLoad(); Contract.Assert(0 < cfg.Plugins.Count, "No plugins loaded. Cannot continue."); // get credentials to connect to Appclusive HOST server var credentialSection = ConfigurationManager.GetSection(AppclusiveCredentialSection.SECTION_NAME) as AppclusiveCredentialSection; if(null == credentialSection) { Trace.WriteLine("No credential in app.config section '{0}' defined. Using 'DefaultNetworkCredentials'.", AppclusiveCredentialSection.SECTION_NAME, ""); cfg.Credential = CredentialCache.DefaultNetworkCredentials; } else { Trace.WriteLine("Credential in app.config section '{0}' found. Using '{1}\\{2}'.", AppclusiveCredentialSection.SECTION_NAME, credentialSection.Domain, credentialSection.Username); var networkCredential = new NetworkCredential(credentialSection.Username, credentialSection.Password, credentialSection.Domain); Contract.Assert(null != networkCredential); cfg.Credential = networkCredential; } }