private void RegisterMigrationSourceAnalysisAddin(Guid migrationSourceId, MigrationSource migrationSource, AnalysisAddin analysisAddin)
 {
     if (!m_analysisAddinsByMigrationSource.ContainsKey(migrationSourceId))
     {
         m_analysisAddinsByMigrationSource.Add(migrationSourceId, new List <AnalysisAddin>());
     }
     m_analysisAddinsByMigrationSource[migrationSourceId].Add(analysisAddin);
     TraceManager.TraceInformation(String.Format(MigrationToolkitResources.LoadedAnalysisAddin,
                                                 analysisAddin.GetType().ToString(), migrationSource.FriendlyName));
 }
        public void RegisterMigrationSourceAddins(Dictionary <Guid, MigrationSource> migrationSources)
        {
            foreach (KeyValuePair <Guid, MigrationSource> keyValuePair in migrationSources)
            {
                if (keyValuePair.Value.Settings != null && keyValuePair.Value.Settings.Addins != null)
                {
                    foreach (AddinElement addinElement in keyValuePair.Value.Settings.Addins.Addin)
                    {
                        IAddin addin = GetAddin(new Guid(addinElement.ReferenceName));

                        AnalysisAddin analysisAddin = addin as AnalysisAddin;
                        if (analysisAddin != null)
                        {
                            RegisterMigrationSourceAnalysisAddin(keyValuePair.Key, keyValuePair.Value, analysisAddin);
                        }

                        MigrationAddin migrationAddin = addin as MigrationAddin;
                        if (migrationAddin != null)
                        {
                            RegisterMigrationSourceMigrationAddin(keyValuePair.Key, keyValuePair.Value, migrationAddin);
                        }
                    }
                }

                // BEGIN SUPPORT FOR COMPATABILITY WITH OLD CONFIG FILES
                try
                {
                    List <string> analysisAddinNames = new List <string>();

                    foreach (CustomSetting setting in keyValuePair.Value.CustomSettings.CustomSetting)
                    {
                        if (setting.SettingKey.StartsWith(MigrationToolkitResources.AnalysisAddinKeyName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            analysisAddinNames.Add(setting.SettingValue);
                        }
                    }

                    foreach (string analysisAddinName in analysisAddinNames)
                    {
                        AnalysisAddin analysisAddin = GetAddin(new Guid(analysisAddinName)) as AnalysisAddin;
                        if (analysisAddin != null)
                        {
                            RegisterMigrationSourceAnalysisAddin(keyValuePair.Key, keyValuePair.Value, analysisAddin);
                        }
                        else
                        {
                            // TODO: Raise error
                            TraceManager.TraceWarning(String.Format(MigrationToolkitResources.AnalysisAddinNotFound, analysisAddinName));
                        }
                    }
                }
                catch (Exception ex)
                {
                    // TODO: Raise error
                    TraceManager.TraceError(String.Format(MigrationToolkitResources.ExceptionLoadingAnalysisAddin, ex.ToString()));
                }

                try
                {
                    List <string> migrationAddinNames = new List <string>();

                    foreach (CustomSetting setting in keyValuePair.Value.CustomSettings.CustomSetting)
                    {
                        if (setting.SettingKey.StartsWith(MigrationToolkitResources.MigrationAddinKeyName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            migrationAddinNames.Add(setting.SettingValue);
                        }
                    }

                    foreach (string migrationAddinName in migrationAddinNames)
                    {
                        MigrationAddin migrationAddin = GetAddin(new Guid(migrationAddinName)) as MigrationAddin;
                        if (migrationAddin != null)
                        {
                            RegisterMigrationSourceMigrationAddin(keyValuePair.Key, keyValuePair.Value, migrationAddin);
                        }
                        else
                        {
                            // TODO: Raise error
                            TraceManager.TraceWarning(String.Format(MigrationToolkitResources.MigrationAddinNotFound, migrationAddinName));
                        }
                    }
                }
                catch (Exception ex)
                {
                    // TODO: Raise error
                    TraceManager.TraceError(String.Format(MigrationToolkitResources.ExceptionLoadingMigrationAddin, ex.ToString()));
                }
                // END SUPPORT FOR COMPATABILITY WITH OLD CONFIG FILES
            }
        }