public async Task <IProjectConfigurationSettingsAccess> OpenProjectSettingsAccessAsync(
            UnconfiguredProject unconfiguredProject, IRProjectProperties propertes)
        {
            Check.ArgumentNull(nameof(unconfiguredProject), unconfiguredProject);
            Check.ArgumentNull(nameof(propertes), propertes);
            SettingsAccess access = null;

            await _semaphore.WaitAsync();

            try {
                string projectFolder = Path.GetDirectoryName(unconfiguredProject.FullPath);
                if (!_settings.TryGetValue(projectFolder, out access))
                {
                    var settings = await OpenCollectionAsync(projectFolder, propertes);

                    var th = unconfiguredProject.Services?.ExportProvider?.GetExportedValue <IThreadHandling>();
                    access = new SettingsAccess(this, th, projectFolder, propertes, settings);
                    _settings[projectFolder] = access;
                }
                access.Counter.Increment();
            } finally {
                _semaphore.Release();
            }
            return(access);
        }
        public static async Task <string> ToRRemotePathAsync(this IRProjectProperties properties, string projectRelativeFilePath)
        {
            string remotePath = await properties.GetRemoteProjectPathAsync();

            string projectName = properties.GetProjectName();

            return((remotePath + projectName + "/" + projectRelativeFilePath).ToRPath());
        }
示例#3
0
        public static async Task <string> ToRRemotePathAsync(this IRProjectProperties properties, string projectRelativeFilePath)
        {
            string remotePath = await properties.GetRemoteProjectPathAsync();

            string projectName = properties.GetProjectName();

            return(($"{remotePath}/{projectName}/{projectRelativeFilePath}").ToRPath().Replace("//", "/"));
        }
        private async Task <string> GetSettingsFilePathAsync(string projectFolder, IRProjectProperties properties)
        {
            var settingsFile = await properties.GetSettingsFileAsync();

            if (!string.IsNullOrEmpty(settingsFile))
            {
                return(settingsFile.MakeAbsolutePathFromRRelative(projectFolder));
            }
            return(null);
        }
示例#5
0
        public async Task SetProjectAsync(UnconfiguredProject project, IRProjectProperties properties) {
            if(_access != null) {
                throw new InvalidOperationException("Project is already set");
            }
            _access = await _settingsProvider.OpenProjectSettingsAccessAsync(project, properties);
            _viewModel = new SettingsPageViewModel(_access.Settings, _appShell, _fs);
            await _viewModel.SetProjectPathAsync(Path.GetDirectoryName(project.FullPath), properties);

            PopulateFilesCombo();
            LoadPropertyGrid();

            _access.Settings.CollectionChanged += OnSettingsCollectionChanged;
        }
            public SettingsAccess(ProjectConfigurationSettingsProvider provider, IThreadHandling threadHandling,
                                  string projectPath, IRProjectProperties propertes, ConfigurationSettingCollection settings)
            {
                _provider       = provider;
                _threadHandling = threadHandling;
                _projectPath    = projectPath;
                _properties     = propertes;

                _counter = new CountdownDisposable(Release);

                Settings = settings;
                Settings.CollectionChanged += OnCollectionChanged;
            }
示例#7
0
        public async Task SetProjectAsync(UnconfiguredProject project, IRProjectProperties properties)
        {
            if (_access != null)
            {
                throw new InvalidOperationException("Project is already set");
            }
            _access = await _settingsProvider.OpenProjectSettingsAccessAsync(project, properties);

            _viewModel = new SettingsPageViewModel(_access.Settings, _shell, _fs);
            await _viewModel.SetProjectPathAsync(Path.GetDirectoryName(project.FullPath), properties);

            PopulateFilesCombo();
            LoadPropertyGrid();

            _access.Settings.CollectionChanged += OnSettingsCollectionChanged;
        }
        public ProjectSettingsControlTest(PackageTestFilesFixture files) {
            _files = files;
            _appShell = Substitute.For<IApplicationShell>();
            _fs = Substitute.For<IFileSystem>();

            _access = Substitute.For<IProjectConfigurationSettingsAccess>();
            _access.Settings.Returns(_coll);

            _csp = Substitute.For<IProjectConfigurationSettingsProvider>();
            _csp.OpenProjectSettingsAccessAsync(null, null).ReturnsForAnyArgs(Task.FromResult(_access));

            _unconfiguredProject = Substitute.For<UnconfiguredProject>();
            _unconfiguredProject.FullPath.Returns(@"C:\file.rproj");

            _properties = Substitute.For<IRProjectProperties>();
            _properties.GetSettingsFileAsync().Returns(Task.FromResult<string>(null));
        }
示例#9
0
        public async Task SetProjectPathAsync(string projectPath, IRProjectProperties properties) {
            _projectPath = projectPath;
            _properties = properties;
            try {
                EnumerateSettingFiles(projectPath);
            } catch (COMException) { } catch (IOException) { } catch (UnauthorizedAccessException) { }

            if (_properties != null) {
                var file = await _properties.GetSettingsFileAsync();
                if (!string.IsNullOrEmpty(file) && _filesMap.ContainsKey(file)) {
                    CurrentFile = file;
                }
            }

            if (CurrentFile == null) {
                CurrentFile = _filesMap.Keys.FirstOrDefault();
            }
        }
        public ProjectSettingsControlTest(PackageTestFilesFixture files)
        {
            _files = files;
            _shell = Substitute.For <ICoreShell>();
            _fs    = Substitute.For <IFileSystem>();

            _access = Substitute.For <IProjectConfigurationSettingsAccess>();
            _access.Settings.Returns(_coll);

            _csp = Substitute.For <IProjectConfigurationSettingsProvider>();
            _csp.OpenProjectSettingsAccessAsync(null, null).ReturnsForAnyArgs(Task.FromResult(_access));

            _unconfiguredProject = Substitute.For <UnconfiguredProject>();
            _unconfiguredProject.FullPath.Returns(@"C:\file.rproj");

            _properties = Substitute.For <IRProjectProperties>();
            _properties.GetSettingsFileAsync().Returns(Task.FromResult <string>(null));
        }
示例#11
0
        public async Task SetProjectPathAsync(string projectPath, IRProjectProperties properties)
        {
            _projectPath = projectPath;
            _properties  = properties;
            try {
                EnumerateSettingFiles(projectPath);
            } catch (COMException) { } catch (IOException) { } catch (UnauthorizedAccessException) { }

            if (_properties != null)
            {
                var file = await _properties.GetSettingsFileAsync();

                if (!string.IsNullOrEmpty(file) && _filesMap.ContainsKey(file))
                {
                    CurrentFile = file;
                }
            }

            if (CurrentFile == null)
            {
                CurrentFile = _filesMap.Keys.FirstOrDefault();
            }
        }
示例#12
0
 public RunPageViewModel(IRProjectProperties[] configuredProjectsProperties) {
     _configuredProjectsProperties = configuredProjectsProperties;
 }
        private void ReleaseSettings(string projectPath, IThreadHandling threadHandling, IRProjectProperties propertes, bool save)
        {
            _semaphore.Wait();
            try {
                var    access       = _settings[projectPath];
                string settingsFile = null;
                if (string.IsNullOrEmpty(access.Settings.SourceFile))
                {
                    settingsFile = Path.Combine(projectPath, "Settings.R");
                }
                if (save)
                {
                    access.Settings.Save(settingsFile);
                }

                threadHandling?.ExecuteSynchronously(async() => {
                    var currentSettingsFile = await propertes.GetSettingsFileAsync();
                    if (string.IsNullOrEmpty(currentSettingsFile))
                    {
                        settingsFile = settingsFile.MakeRRelativePath(projectPath);
                        await propertes.SetSettingsFileAsync(settingsFile);
                    }
                });
                _settings.Remove(projectPath);
            } finally {
                _semaphore.Release();
            }
        }
        private async Task <ConfigurationSettingCollection> OpenCollectionAsync(string projectFolder, IRProjectProperties properties)
        {
            var settings         = new ConfigurationSettingCollection();
            var settingsFilePath = await GetSettingsFilePathAsync(projectFolder, properties);

            if (!string.IsNullOrEmpty(settingsFilePath))
            {
                settings.Load(settingsFilePath.MakeAbsolutePathFromRRelative(projectFolder));
            }
            return(settings);
        }