/// <summary>
        /// Copies the settings group.
        /// </summary>
        /// <param name="sourceSettings">The source settings.</param>
        /// <param name="targetSettings">The target settings.</param>
        /// <param name="settingsGroupId">The settings group identifier.</param>
        /// <param name="targetProject">The target project.</param>
        /// <param name="targetLanguage">The target language.</param>
        private void CopySettingsGroup(ISettingsBundle sourceSettings, ISettingsBundle targetSettings, string settingsGroupId, FileBasedProject targetProject, Language targetLanguage)
        {
            if (!string.IsNullOrEmpty(settingsGroupId))
            {
                if (targetSettings.ContainsSettingsGroup(settingsGroupId))
                {
                    targetSettings.RemoveSettingsGroup(settingsGroupId);
                }

                if (sourceSettings.ContainsSettingsGroup(settingsGroupId))
                {
                    ISettingsGroup sourceSettingsGroup = sourceSettings.GetSettingsGroup(settingsGroupId);
                    ISettingsGroup targetSettingsGroup = targetSettings.GetSettingsGroup(settingsGroupId);
                    targetSettingsGroup.ImportSettings(sourceSettingsGroup);
                    if (targetLanguage == null)
                    {
                        targetProject.UpdateSettings(targetSettings);
                    }
                    else
                    {
                        targetProject.UpdateSettings(targetLanguage, targetSettings);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void RemoveSettings(ISettingsBundle projectSettingsBundle)
 {
     if (projectSettingsBundle is null)
     {
         return;
     }
     if (!projectSettingsBundle.ContainsSettingsGroup(nameof(BatchAnonymizerSettings)))
     {
         return;
     }
     projectSettingsBundle.RemoveSettingsGroup(nameof(BatchAnonymizerSettings));
 }
        private bool CopySettingsGroup(ISettingsBundle sourceSettings, ISettingsBundle targetSettings,
                                       string settingsGroupId, FileBasedProject targetProject)
        {
            if (string.IsNullOrEmpty(settingsGroupId))
            {
                return(false);
            }

            if (!sourceSettings.ContainsSettingsGroup(settingsGroupId))
            {
                return(false);
            }

            if (targetSettings.ContainsSettingsGroup(settingsGroupId))
            {
                targetSettings.RemoveSettingsGroup(settingsGroupId);
            }
            var sourceSettingsGroup = sourceSettings.GetSettingsGroup(settingsGroupId);
            var targetSettingsGroup = targetSettings.GetSettingsGroup(settingsGroupId);

            targetSettingsGroup.ImportSettings(sourceSettingsGroup);
            targetProject.UpdateSettings(targetSettings);
            return(true);
        }