protected override void Act()
        {
            sourceFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config");
            File.SetAttributes(sourceFile, FileAttributes.ReadOnly);

            ConfigurationMerger configurationMerger = new ConfigurationMerger(sourceFile, MergeSection);

            configurationMerger.MergeConfiguration(TargetFile);
        }
        protected override void Act()
        {
            var resources = new ResourceHelper<ConfigFileLocator>();
            var deltaConfigurationFile = resources.DumpResourceFileToDisk("override_lab_protection_dpapi.dconfig");
            
            ConfigurationMerger configurationMerger = new ConfigurationMerger(mainConfigurationFile, deltaConfigurationFile);
            configurationMerger.MergeConfiguration(mergedConfigurationFile);

            mergedConfigurationFileSource = new FileConfigurationSource(mergedConfigurationFile);
        }
        protected override void Act()
        {
            var resources = new ResourceHelper <ConfigFileLocator>();
            var deltaConfigurationFile = resources.DumpResourceFileToDisk("override_lab_protection_dpapi.dconfig");

            ConfigurationMerger configurationMerger = new ConfigurationMerger(mainConfigurationFile, deltaConfigurationFile);

            configurationMerger.MergeConfiguration(mergedConfigurationFile);

            mergedConfigurationFileSource = new FileConfigurationSource(mergedConfigurationFile);
        }
        protected override void Act()
        {
            lastWriteTime = DateTime.Today.Subtract(TimeSpan.FromMinutes(5));

            File.Create(TargetFile).Dispose();
            File.SetLastWriteTime(TargetFile, lastWriteTime);

            ConfigurationMerger configurationMerger = new ConfigurationMerger(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config"), MergeSection);

            configurationMerger.MergeConfiguration(TargetFile);
        }
        protected override void Act()
        {
            openFile      = File.Create(TargetFile);
            lastWriteTime = File.GetLastWriteTime(TargetFile);

            try
            {
                ConfigurationMerger configurationMerger = new ConfigurationMerger(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config"), MergeSection);
                configurationMerger.MergeConfiguration(TargetFile);
            }
            catch (IOException)
            {
            }
        }
        static int Main(string[] args)
        {
            if (args.Length < 2 || args.Length > 3)
            {
                PrintUsage();
                return 1;
            }

            string mainConfigurationFile = Path.GetFullPath(args[0]);
            string configurationMergeFile = Path.GetFullPath(args[1]);
            string mergedConfigurationFile = (args.Length == 3) ? Path.GetFullPath(args[2]) : string.Empty;


            if (!File.Exists(mainConfigurationFile))
            {
                string errorMessage = string.Format(Resources.MainConfigurationFileNotFound, mainConfigurationFile);
                System.Console.WriteLine(errorMessage);

                return 1;
            }

            if (!File.Exists(configurationMergeFile))
            {
                string errorMessage = string.Format(Resources.ConfigurationMergeFileNotFound, configurationMergeFile);
                System.Console.WriteLine(errorMessage);

                return 1;
            }

            try
            {
                ConfigurationMerger mergeTool = new ConfigurationMerger(mainConfigurationFile, configurationMergeFile);
                mergeTool.MergeConfiguration(mergedConfigurationFile);

                string message = String.Format(Resources.MergeSucceeded, mergeTool.MergedConfigurationFile);
                System.Console.WriteLine(message);
                
            }
            catch (Exception e)
            {
                System.Console.WriteLine(Resources.UnhandledExceptionMessage);
                System.Console.WriteLine(e);
                return 1;
            }
            return 0;
        }
Beispiel #7
0
        static int Main(string[] args)
        {
            if (args.Length < 2 || args.Length > 3)
            {
                PrintUsage();
                return(1);
            }

            string mainConfigurationFile   = Path.GetFullPath(args[0]);
            string configurationMergeFile  = Path.GetFullPath(args[1]);
            string mergedConfigurationFile = (args.Length == 3) ? Path.GetFullPath(args[2]) : string.Empty;


            if (!File.Exists(mainConfigurationFile))
            {
                string errorMessage = string.Format(Resources.MainConfigurationFileNotFound, mainConfigurationFile);
                System.Console.WriteLine(errorMessage);

                return(1);
            }

            if (!File.Exists(configurationMergeFile))
            {
                string errorMessage = string.Format(Resources.ConfigurationMergeFileNotFound, configurationMergeFile);
                System.Console.WriteLine(errorMessage);

                return(1);
            }

            try
            {
                ConfigurationMerger mergeTool = new ConfigurationMerger(mainConfigurationFile, configurationMergeFile);
                mergeTool.MergeConfiguration(mergedConfigurationFile);

                string message = String.Format(Resources.MergeSucceeded, mergeTool.MergedConfigurationFile);
                System.Console.WriteLine(message);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(Resources.UnhandledExceptionMessage);
                System.Console.WriteLine(e);
                return(1);
            }
            return(0);
        }
 protected override void Act()
 {
     ConfigurationMerger configurationMerger = new ConfigurationMerger(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config"), MergeSection);
     configurationMerger.MergeConfiguration(TargetFile);
 }
        protected override void Act()
        {
            openFile = File.Create(TargetFile);
            lastWriteTime = File.GetLastWriteTime(TargetFile);

            try
            {
                ConfigurationMerger configurationMerger = new ConfigurationMerger(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config"), MergeSection);
                configurationMerger.MergeConfiguration(TargetFile);
            }
            catch (IOException)
            {
            }
        }
        protected override void Act()
        {
            sourceFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config");
            File.SetAttributes(sourceFile, FileAttributes.ReadOnly);

            ConfigurationMerger configurationMerger = new ConfigurationMerger(sourceFile, MergeSection);
            configurationMerger.MergeConfiguration(TargetFile);
        }
        protected override void Act()
        {
            lastWriteTime = DateTime.Today.Subtract(TimeSpan.FromMinutes(5));
            
            File.Create(TargetFile).Dispose();
            File.SetLastWriteTime(TargetFile, lastWriteTime);

            ConfigurationMerger configurationMerger = new ConfigurationMerger(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config"), MergeSection);
            configurationMerger.MergeConfiguration(TargetFile);
        }
        protected override void Act()
        {
            ConfigurationMerger configurationMerger = new ConfigurationMerger(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "merge_main.config"), MergeSection);

            configurationMerger.MergeConfiguration(TargetFile);
        }
        protected override void InnerExecute(object parameter)
        {
            var configurationSourceSection = configurationSource.Sections.OfType <ConfigurationSourceSectionViewModel>().FirstOrDefault();

            if (configurationSourceSection != null)
            {
                ElementReferenceProperty selectedSourceProperty = (ElementReferenceProperty)configurationSourceSection.Property("SelectedSource");

                if (typeof(SystemConfigurationSourceElement) != selectedSourceProperty.ReferencedElement.ConfigurationType)
                {
                    UIService.ShowMessageWpf(DesignResources.ExportingEnvironemntConfigurationUsingNonSystemSource, DesignResources.ExportMergedEnvironmentTitle, MessageBoxButton.OK);
                    return;
                }
            }
            if (application.IsDirty)
            {
                var saveDialogResult = UIService.ShowMessageWpf(
                    DesignResources.ExportMergedUnsavedMainConfigurationMessage,
                    DesignResources.ExportMergedConfigurationTitle,
                    System.Windows.MessageBoxButton.OKCancel);

                if (saveDialogResult == System.Windows.MessageBoxResult.Cancel)
                {
                    return;
                }
                if (!application.Save())
                {
                    return;
                }
            }

            string mergedConfigurationFile = (string)overridesViewModel.Property("EnvironmentConfigurationFile").Value;

            if (string.IsNullOrEmpty(mergedConfigurationFile))
            {
                SaveFileDialog saveEnvrionmentDialog = new SaveFileDialog()
                {
                    Title       = DesignResources.ExportMergedConfigurationTitle,
                    DefaultExt  = "*.config",
                    Filter      = Resources.SaveConfigurationFileDialogFilter,
                    FilterIndex = 0
                };

                var saveFileResults = UIService.ShowFileDialog(saveEnvrionmentDialog);
                if (saveFileResults.DialogResult != true)
                {
                    return;
                }
                mergedConfigurationFile = saveFileResults.FileName;
            }
            else
            {
                if (File.Exists(mergedConfigurationFile))
                {
                    var confirmationResult = UIService.ShowMessageWpf(
                        string.Format(CultureInfo.CurrentCulture, DesignResources.SaveOverwriteMergedFile, mergedConfigurationFile),
                        DesignResources.ExportMergedConfigurationTitle, MessageBoxButton.YesNo);

                    if (confirmationResult == MessageBoxResult.No)
                    {
                        return;
                    }
                }
            }

            if (!Path.IsPathRooted(mergedConfigurationFile))
            {
                string configurationFileDirectory = Path.GetDirectoryName(application.ConfigurationFilePath);
                mergedConfigurationFile = Path.Combine(configurationFileDirectory, mergedConfigurationFile);
            }

            ConfigurationMerger mergeComponent = new ConfigurationMerger(application.ConfigurationFilePath, (EnvironmentalOverridesSection)overridesViewModel.ConfigurationElement);

            mergeComponent.MergeConfiguration(mergedConfigurationFile);

            overridesViewModel.Property("EnvironmentConfigurationFile").Value = mergedConfigurationFile;
        }
        protected override void InnerExecute(object parameter)
        {
            var configurationSourceSection = configurationSource.Sections.OfType<ConfigurationSourceSectionViewModel>().FirstOrDefault();
            if (configurationSourceSection != null)
            {
                ElementReferenceProperty selectedSourceProperty = (ElementReferenceProperty) configurationSourceSection.Property("SelectedSource");

                if (typeof(SystemConfigurationSourceElement) != selectedSourceProperty.ReferencedElement.ConfigurationType)
                {
                    UIService.ShowMessageWpf(DesignResources.ExportingEnvironemntConfigurationUsingNonSystemSource, DesignResources.ExportMergedEnvironmentTitle, MessageBoxButton.OK);
                    return;
                }
            }
            if (application.IsDirty)
            {
                var saveDialogResult = UIService.ShowMessageWpf(
                    DesignResources.ExportMergedUnsavedMainConfigurationMessage,
                    DesignResources.ExportMergedConfigurationTitle,
                    System.Windows.MessageBoxButton.OKCancel);

                if (saveDialogResult == System.Windows.MessageBoxResult.Cancel)
                {
                    return;
                }
                if (!application.Save())
                {
                    return;
                }
            }

            string mergedConfigurationFile = (string)overridesViewModel.Property("EnvironmentConfigurationFile").Value;

            if (string.IsNullOrEmpty(mergedConfigurationFile))
            {
                SaveFileDialog saveEnvrionmentDialog = new SaveFileDialog()
                    {
                        Title = DesignResources.ExportMergedConfigurationTitle,
                        DefaultExt = "*.config",
                        Filter = Resources.SaveConfigurationFileDialogFilter,
                        FilterIndex = 0
                    };

                var saveFileResults = UIService.ShowFileDialog(saveEnvrionmentDialog);
                if (saveFileResults.DialogResult != true)
                {
                    return;
                }
                mergedConfigurationFile = saveFileResults.FileName;
            }
            else
            {
                if (File.Exists(mergedConfigurationFile))
                {
                    var confirmationResult = UIService.ShowMessageWpf(
                        string.Format(CultureInfo.CurrentCulture, DesignResources.SaveOverwriteMergedFile, mergedConfigurationFile),
                        DesignResources.ExportMergedConfigurationTitle, MessageBoxButton.YesNo);

                    if (confirmationResult == MessageBoxResult.No)
                    {
                        return;
                    }
                }
            }

            if (!Path.IsPathRooted(mergedConfigurationFile))
            {
                string configurationFileDirectory = Path.GetDirectoryName(application.ConfigurationFilePath);
                mergedConfigurationFile = Path.Combine(configurationFileDirectory, mergedConfigurationFile);
            }

            ConfigurationMerger mergeComponent = new ConfigurationMerger(application.ConfigurationFilePath, (EnvironmentalOverridesSection)overridesViewModel.ConfigurationElement);
            mergeComponent.MergeConfiguration(mergedConfigurationFile);

            overridesViewModel.Property("EnvironmentConfigurationFile").Value = mergedConfigurationFile;
        }