private static void InitializeContainer() { XmlMergeUtil.MergeConfiguration(@"McAfeeLabs.Engineering.Automation.Base.MD5SampleBatchDownloadUnityContainerFactory", @"XpathMerge.xml", Assembly.GetAssembly(typeof(MD5SampleBatchDownLoadUnityContainerFactory)), @".\Dynamic.config"); _container = new UnityContainer(); _container.LoadConfiguration(); }
protected void InitializeModuleDynamicConfig() { const string dynamicConfigFileName = @".\Dyanmic.config"; var serviceNamespace = this.GetType().Namespace; string mergeScriptName = @"DefaultPlugins.XpathMergeRelease.xml"; #if DEBUG mergeScriptName = @"DefaultPlugins.XpathMergeDebug.xml"; #endif var dynamicconfig = new DynamicConfiguration(); var executingAssembly = Assembly.GetExecutingAssembly(); var pluginFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginManager.DefaultDomainName); ModulePluginLoader.LoadDefaultModulePlugins(pluginFolder, new SQLConfigProvider(executingAssembly)); //Merge the profile database connection in order to query configuration from DB XmlMergeUtil.MergeConfiguration(serviceNamespace, mergeScriptName, executingAssembly, dynamicConfigFileName, _logger); var profile = _modulename.QueryProfile(AppTypeEnum.exe, _profileName, ProfileTypeEnum.config); File.Delete(dynamicConfigFileName); if (null == profile || string.IsNullOrEmpty(profile.XmlPayload)) { //Switch back to original configuration if failed to query configuration from DB //If query the centralized configuration failed for any reason. var currentConfigPath = string.Format(@"{0}{1}.exe.config", AppDomain.CurrentDomain.BaseDirectory, _entryAssembly.GetName().Name); dynamicconfig.SwitchConfigSource(currentConfigPath); ModulePluginLoader.InitializeLogger(out _logger, this); Directory.Delete(pluginFolder, true); return; } //hook up configuration update notification when the updating occurs from DB, the loacal configuration will sync automatically. Then this call is //done the current configuration will sync the the configuration retrieved from the Db and automatically synchronized if there are updated from Db. ModulePluginLoader.LoadModulePlugin(_defaultPluginsDomainFolder, new SQLConfigProvider(_entryAssembly) { ProfileFileName = _profileName, UpdateCheckInterval = 10 * 1000, TargetPath = @".\" }, this); }