change networkservice to communitytoolkit networkhelper

This commit is contained in:
2024-03-04 00:49:15 +01:00
Unverified
parent 3ddb8e73e3
commit f949954130
10 changed files with 14 additions and 44 deletions

View File

@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI.Helpers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -9,7 +10,6 @@ using System.Threading.Tasks;
using VDownload.Core.Tasks; using VDownload.Core.Tasks;
using VDownload.Services.UI.Dialogs; using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources; using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.Network;
namespace VDownload.Core.ViewModels.Home namespace VDownload.Core.ViewModels.Home
{ {
@@ -19,7 +19,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IDownloadTaskManager _tasksManager; protected readonly IDownloadTaskManager _tasksManager;
protected readonly INetworkService _networkService;
protected readonly IDialogsService _dialogsService; protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService; protected readonly IStringResourcesService _stringResourcesService;
@@ -40,12 +39,11 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS #region CONSTRUCTORS
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService) public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
{ {
_tasksManager = tasksManager; _tasksManager = tasksManager;
_tasksManager.TaskCollectionChanged += Tasks_CollectionChanged; _tasksManager.TaskCollectionChanged += Tasks_CollectionChanged;
_networkService = networkService;
_dialogsService = dialogsService; _dialogsService = dialogsService;
_stringResourcesService = stringResourcesService; _stringResourcesService = stringResourcesService;
@@ -71,7 +69,7 @@ namespace VDownload.Core.ViewModels.Home
if (idleStatuses.Contains(task.Status)) if (idleStatuses.Contains(task.Status))
{ {
bool continueEnqueue = true; bool continueEnqueue = true;
if (_networkService.IsMetered) if (NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{ {
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -19,7 +19,7 @@ using System.Text.RegularExpressions;
using VDownload.Services.Utility.Filename; using VDownload.Services.Utility.Filename;
using VDownload.Services.UI.Dialogs; using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources; using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.Network; using CommunityToolkit.WinUI.Helpers;
namespace VDownload.Core.ViewModels.Home namespace VDownload.Core.ViewModels.Home
{ {
@@ -32,7 +32,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly ISettingsService _settingsService; protected readonly ISettingsService _settingsService;
protected readonly IStoragePickerService _storagePickerService; protected readonly IStoragePickerService _storagePickerService;
protected readonly IFilenameService _filenameService; protected readonly IFilenameService _filenameService;
protected readonly INetworkService _networkService;
protected readonly IDialogsService _dialogsService; protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService; protected readonly IStringResourcesService _stringResourcesService;
@@ -180,13 +179,12 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS #region CONSTRUCTORS
public HomePlaylistViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService) public HomePlaylistViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
{ {
_tasksManager = tasksManager; _tasksManager = tasksManager;
_settingsService = settingsService; _settingsService = settingsService;
_storagePickerService = storagePickerService; _storagePickerService = storagePickerService;
_filenameService = filenameService; _filenameService = filenameService;
_networkService = networkService;
_dialogsService = dialogsService; _dialogsService = dialogsService;
_stringResourcesService = stringResourcesService; _stringResourcesService = stringResourcesService;
@@ -293,7 +291,7 @@ namespace VDownload.Core.ViewModels.Home
protected async Task CreateTasks(bool download) protected async Task CreateTasks(bool download)
{ {
if (download && _networkService.IsMetered) if (download && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{ {
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI.Helpers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -14,7 +15,6 @@ using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StoragePicker; using VDownload.Services.UI.StoragePicker;
using VDownload.Services.UI.StringResources; using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.Filename; using VDownload.Services.Utility.Filename;
using VDownload.Services.Utility.Network;
namespace VDownload.Core.ViewModels.Home namespace VDownload.Core.ViewModels.Home
{ {
@@ -27,7 +27,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly ISettingsService _settingsService; protected readonly ISettingsService _settingsService;
protected readonly IStoragePickerService _storagePickerService; protected readonly IStoragePickerService _storagePickerService;
protected readonly IFilenameService _filenameService; protected readonly IFilenameService _filenameService;
protected readonly INetworkService _networkService;
protected readonly IDialogsService _dialogsService; protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService; protected readonly IStringResourcesService _stringResourcesService;
@@ -97,13 +96,12 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS #region CONSTRUCTORS
public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService) public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
{ {
_tasksManager = tasksManager; _tasksManager = tasksManager;
_settingsService = settingsService; _settingsService = settingsService;
_storagePickerService = storagePickerService; _storagePickerService = storagePickerService;
_filenameService = filenameService; _filenameService = filenameService;
_networkService = networkService;
_dialogsService = dialogsService; _dialogsService = dialogsService;
_stringResourcesService = stringResourcesService; _stringResourcesService = stringResourcesService;
} }
@@ -163,7 +161,7 @@ namespace VDownload.Core.ViewModels.Home
protected async Task CreateTask(bool download) protected async Task CreateTask(bool download)
{ {
if (download && _networkService.IsMetered) if (download && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{ {
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI.Helpers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -11,7 +12,6 @@ using VDownload.Services.Data.Configuration;
using VDownload.Services.Data.Settings; using VDownload.Services.Data.Settings;
using VDownload.Services.UI.Dialogs; using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources; using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.Network;
using VDownload.Sources; using VDownload.Sources;
using VDownload.Sources.Common; using VDownload.Sources.Common;
using VDownload.Sources.Twitch.Configuration.Models; using VDownload.Sources.Twitch.Configuration.Models;
@@ -52,7 +52,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly ISettingsService _settingsService; protected readonly ISettingsService _settingsService;
protected readonly IStringResourcesService _stringResourcesService; protected readonly IStringResourcesService _stringResourcesService;
protected readonly ISearchService _searchService; protected readonly ISearchService _searchService;
protected readonly INetworkService _networkService;
protected readonly IDialogsService _dialogsService; protected readonly IDialogsService _dialogsService;
protected readonly IDownloadTaskManager _downloadTaskManager; protected readonly IDownloadTaskManager _downloadTaskManager;
@@ -113,13 +112,12 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS #region CONSTRUCTORS
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, INetworkService networkService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomePlaylistViewModel playlistViewModel) public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomePlaylistViewModel playlistViewModel)
{ {
_configurationService = configurationService; _configurationService = configurationService;
_settingsService = settingsService; _settingsService = settingsService;
_stringResourcesService = stringResourcesService; _stringResourcesService = stringResourcesService;
_searchService = searchService; _searchService = searchService;
_networkService = networkService;
_dialogsService = dialogsService; _dialogsService = dialogsService;
_downloadTaskManager = downloadTaskManager; _downloadTaskManager = downloadTaskManager;
@@ -267,7 +265,7 @@ namespace VDownload.Core.ViewModels.Home
[RelayCommand] [RelayCommand]
public async Task Download() public async Task Download()
{ {
if (_downloadTaskManager.Tasks.Count > 0 && _networkService.IsMetered) if (_downloadTaskManager.Tasks.Count > 0 && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{ {
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -10,6 +10,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" /> <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" /> <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
@@ -18,7 +19,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VDownload.Services.Utility.Network\VDownload.Services.Utility.Network.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" /> <ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.Dialogs\VDownload.Services.UI.Dialogs.csproj" /> <ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.Dialogs\VDownload.Services.UI.Dialogs.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.DictionaryResources\VDownload.Services.UI.DictionaryResources.csproj" /> <ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.DictionaryResources\VDownload.Services.UI.DictionaryResources.csproj" />

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@@ -71,8 +71,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility.Filename", "VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.Filename\VDownload.Services.Utility.Filename.csproj", "{4647EFB5-A206-4F47-976D-BAED11B52579}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility.Filename", "VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.Filename\VDownload.Services.Utility.Filename.csproj", "{4647EFB5-A206-4F47-976D-BAED11B52579}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDownload.Services.Utility.Network", "VDownload.Services.Utility.Network\VDownload.Services.Utility.Network.csproj", "{08AEC43D-34C3-4B19-A577-B69FF755BD7F}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -523,22 +521,6 @@ Global
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x64.Build.0 = Release|Any CPU {4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x64.Build.0 = Release|Any CPU
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.ActiveCfg = Release|Any CPU {4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.ActiveCfg = Release|Any CPU
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.Build.0 = Release|Any CPU {4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.Build.0 = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|ARM64.Build.0 = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x64.ActiveCfg = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x64.Build.0 = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x86.ActiveCfg = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x86.Build.0 = Debug|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|Any CPU.Build.0 = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|ARM64.ActiveCfg = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|ARM64.Build.0 = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x64.ActiveCfg = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x64.Build.0 = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x86.ActiveCfg = Release|Any CPU
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -573,7 +555,6 @@ Global
{3BE998A3-1126-4496-BF60-80D0CEA4D24F} = {8539067C-9968-4AEB-928C-FEDC43989A79} {3BE998A3-1126-4496-BF60-80D0CEA4D24F} = {8539067C-9968-4AEB-928C-FEDC43989A79}
{A3166F8A-ECAD-4D4B-9BE3-96FEC799B27B} = {1020167A-4101-496E-82CF-41B65769DD28} {A3166F8A-ECAD-4D4B-9BE3-96FEC799B27B} = {1020167A-4101-496E-82CF-41B65769DD28}
{4647EFB5-A206-4F47-976D-BAED11B52579} = {1020167A-4101-496E-82CF-41B65769DD28} {4647EFB5-A206-4F47-976D-BAED11B52579} = {1020167A-4101-496E-82CF-41B65769DD28}
{08AEC43D-34C3-4B19-A577-B69FF755BD7F} = {1020167A-4101-496E-82CF-41B65769DD28}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9FD7B842-C3E2-4FD0-AD8A-C8E619280AB7} SolutionGuid = {9FD7B842-C3E2-4FD0-AD8A-C8E619280AB7}

View File

@@ -28,7 +28,6 @@ using VDownload.Services.Utility.Encryption;
using VDownload.Services.Utility.FFmpeg; using VDownload.Services.Utility.FFmpeg;
using VDownload.Services.Utility.Filename; using VDownload.Services.Utility.Filename;
using VDownload.Services.Utility.HttpClient; using VDownload.Services.Utility.HttpClient;
using VDownload.Services.Utility.Network;
using VDownload.Sources; using VDownload.Sources;
using VDownload.Sources.Twitch; using VDownload.Sources.Twitch;
using VDownload.Sources.Twitch.Api; using VDownload.Sources.Twitch.Api;
@@ -123,7 +122,6 @@ namespace VDownload
services.AddSingleton<IHttpClientService, HttpClientService>(); services.AddSingleton<IHttpClientService, HttpClientService>();
services.AddSingleton<IFFmpegService, FFmpegService>(); services.AddSingleton<IFFmpegService, FFmpegService>();
services.AddSingleton<IFilenameService, FilenameService>(); services.AddSingleton<IFilenameService, FilenameService>();
services.AddSingleton<INetworkService, NetworkService>();
} }
protected void BuildSourcesServices(IServiceCollection services) protected void BuildSourcesServices(IServiceCollection services)

View File

@@ -170,7 +170,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\VDownload.Core\VDownload.Core.ViewModels\VDownload.Core.ViewModels.csproj" /> <ProjectReference Include="..\VDownload.Core\VDownload.Core.ViewModels\VDownload.Core.ViewModels.csproj" />
<ProjectReference Include="..\VDownload.Core\VDownload.Core.Views\VDownload.Core.Views.csproj" /> <ProjectReference Include="..\VDownload.Core\VDownload.Core.Views\VDownload.Core.Views.csproj" />
<ProjectReference Include="..\VDownload.Services.Utility.Network\VDownload.Services.Utility.Network.csproj" />
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Authentication\VDownload.Services.Data.Authentication.csproj" /> <ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Authentication\VDownload.Services.Data.Authentication.csproj" />
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" /> <ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" /> <ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />