Example #1
0
        public void Load()
        {
            try
            {
                settings = fileSystem.FileExists(Paths.SettingsFile) ? xmlSerializer.LoadFromXml <Settings>(Paths.SettingsFile)
                    : new Settings();

                if (settings.TreeViewCategories.Count == 0)
                {
                    // add default categories
                    settings.TreeViewCategories.AddRange(new[] { "Namespace", MetadataKeys.AuthorName,
                                                                 MetadataKeys.Category, MetadataKeys.Importance, MetadataKeys.TestsOn });
                }
                SelectedTreeViewCategories.Value = new List <string>(settings.TreeViewCategories);

                var unselectedCategories = new List <string>();
                foreach (var fieldInfo in typeof(MetadataKeys).GetFields())
                {
                    if (!settings.TreeViewCategories.Contains(fieldInfo.Name))
                    {
                        unselectedCategories.Add(fieldInfo.Name);
                    }
                }
                UnselectedTreeViewCategories.Value = unselectedCategories;

                TestRunnerFactory.Value = settings.TestRunnerFactory;
            }
            catch (Exception ex)
            {
                unhandledExceptionPolicy.Report("An exception occurred while loading Icarus settings file.", ex);
            }
        }
        private void SafeCopy(IPluginDescriptor plugin, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask(string.Format("Copying {0} plugin", plugin.PluginId), plugin.FilePaths.Count))
            {
                var sourceFolder = Path.Combine(sourcePluginFolder, plugin.RecommendedInstallationPath);
                var targetFolder = Path.Combine(targetPluginFolder, plugin.RecommendedInstallationPath);

                foreach (var file in plugin.FilePaths)
                {
                    var sourceFileInfo = new FileInfo(Path.Combine(sourceFolder, file));
                    var destination    = new FileInfo(Path.Combine(targetFolder, file));

                    try
                    {
                        if (fileSystem.DirectoryExists(destination.DirectoryName) == false)
                        {
                            fileSystem.CreateDirectory(destination.DirectoryName);
                        }

                        fileSystem.CopyFile(sourceFileInfo.FullName, destination.FullName, true);
                    }
                    catch (Exception ex)
                    {
                        exceptionPolicy.Report(string.Format("Error copying file: {0}", file), ex);
                    }
                }
            }
        }
Example #3
0
 private void ProcessFailure(Exception exception, string queueId)
 {
     if (exception is OperationCanceledException)
     {
         eventAggregator.Send(this, new TaskCancelled(queueId));
     }
     else
     {
         unhandledExceptionPolicy.Report("An exception occurred while running a task.",
                                         exception);
     }
 }
        public void OpenProject(IProgressMonitor progressMonitor, string projectLocation)
        {
            using (progressMonitor.BeginTask(Resources.ProjectController_Loading_project_file, 100))
            {
                var testProject = new TestProject();

                try
                {
                    testProject = testProjectManager.LoadProject(new FileInfo(projectLocation));
                }
                catch (Exception ex)
                {
                    unhandledExceptionPolicy.Report(Resources.ProjectController_Error_loading_project_file, ex);
                }

                progressMonitor.Worked(50);
                LoadProject(testProject, projectLocation);
            }
        }
        public void SaveProject(bool queueTask)
        {
            var command = commandFactory.CreateSaveProjectCommand(projectFileName);

            if (queueTask)
            {
                taskManager.QueueTask(command);
            }
            else
            {
                // we're shutting down, so eat any errors
                try
                {
                    command.Execute(NullProgressMonitor.CreateInstance());
                }
                catch (Exception ex)
                {
                    unhandledExceptionPolicy.Report("Error saving project", ex);
                }
            }
        }
Example #6
0
        private void CopyFile(IProgressMonitor progressMonitor, string filePath)
        {
            try
            {
                var destinationFilePath = Path.Combine(destinationFolder, filePath);

                progressMonitor.SetStatus(destinationFilePath);

                var sourceFilePath = Path.Combine(sourceFolder, filePath);

                var destinationDirectory = Path.GetDirectoryName(destinationFilePath);
                if (!fileSystem.DirectoryExists(destinationDirectory))
                {
                    fileSystem.CreateDirectory(destinationDirectory);
                }

                fileSystem.CopyFile(sourceFilePath, destinationFilePath, true);
            }
            catch (Exception ex)
            {
                unhandledExceptionPolicy.Report(string.Format("Error copying file '{0}'.", filePath), ex);
            }
        }
        public void LoadUserOptions(string projectLocation)
        {
            var projectUserOptionsFile = projectLocation + UserOptions.Extension;
            var userOptions            = new UserOptions();

            if (fileSystem.FileExists(projectUserOptionsFile))
            {
                try
                {
                    userOptions = xmlSerializer.LoadFromXml <UserOptions>(projectUserOptionsFile);
                }
                catch (Exception ex)
                {
                    unhandledExceptionPolicy.Report(Resources.UserOptionsController_Failed_to_load_user_options_, ex);
                }
            }

            TreeViewCategory = userOptions.TreeViewCategory;
            eventAggregator.Send(this, new TreeViewCategoryChanged(TreeViewCategory));

            CollapsedNodes = userOptions.CollapsedNodes;

            eventAggregator.Send(this, new UserOptionsLoaded());
        }