Beispiel #1
0
        public async Task UninstallAsync(VersionedModule module)
        {
            ModuleRunnerBase moduleSupervisor;

            using (await _lock.LockAsync())
            {
                if (!_installedModules.TryGetValue(module, out moduleSupervisor))
                {
                    return;
                }

                moduleSupervisor.Complete();

                _installedModules.Remove(module);
            }

            await moduleSupervisor.Completion;

            if (moduleSupervisor is ModuleRunner runner)
            {
                Directory.Delete(runner.Installation.InstallationDirectory, recursive: true);
            }
        }
Beispiel #2
0
        public async Task InstallAsync(VersionedModule module)
        {
            ModuleRunner moduleSupervisor;

            using (await _lock.LockAsync())
            {
                if (_installedModules.ContainsKey(module))
                {
                    return;
                }

                var moduleInstalled             = false;
                ModuleInstallation installation = null;

                foreach (var source in _moduleSources)
                {
                    if ((installation = await source.TryInstallModuleAsync(module, _workingDirectory)) != null)
                    {
                        moduleInstalled = true;
                        break;
                    }
                }

                if (!moduleInstalled)
                {
                    throw new Exception("No source available that can handle the specified module.");
                }

                Debug.Assert(installation != null);

                moduleSupervisor = new ModuleRunner(installation, _serviceProvider);

                _installedModules.Add(module, moduleSupervisor);
            }

            await moduleSupervisor.Initialization;
        }