public ITrashCanService Create() { var platform = _platformService.GetPlatform(); switch (platform) { case Platform.Linux: return(new LinuxTrashCanService(_driveService, _operationsService, _pathService, _environmentService, _fileService, _directoryService)); case Platform.Windows: return(new WindowsTrashCanService(_driveService, _operationsService, _pathService, _fileService, _environmentService, _sid)); case Platform.MacOs: default: throw new ArgumentOutOfRangeException(nameof(platform)); } }
public void Open(string resource) { var platform = _platformService.GetPlatform(); if (platform is Platform.Windows) { _processService.Run(resource); return; } var command = GetCommand(platform); var arguments = $"\"{resource}\""; _processService.Run(command, arguments); }
public async Task DownloadUpdate() { if (Update == null) { return; } var updateFilePrefix = string.Format("{0}{1}", _platformService.GetPlatform(), _isPortable ? "_portable" : string.Empty); Uri url = null; foreach (var download in Update.Downloads) { if (download.Url.Contains(updateFilePrefix, StringComparison.OrdinalIgnoreCase)) { url = new Uri(download.Url, UriKind.Absolute); break; } } if (url == null) { return; } var client = new RestClient(); var request = new RestRequest(url, Method.GET); var response = await client.ExecuteAsync(request); if (response.StatusCode == HttpStatusCode.OK) { if (!Directory.Exists(_sharedService.UpdateConfiguration.DownloadDirectory)) { Directory.CreateDirectory(_sharedService.UpdateConfiguration.DownloadDirectory); } var updateFilePath = Path.Combine(_sharedService.UpdateConfiguration.DownloadDirectory, Path.GetFileName(url.LocalPath)); File.WriteAllBytes(updateFilePath, response.RawBytes); } }
public async Task <ActionResult <PlatformRead> > GetPlatform(Guid id) { var platformRead = await _platformService.GetPlatform(id); return(Ok(platformRead)); }