metered connection warnings added
This commit is contained in:
36
VDownload.Services.Utility.Network/NetworkService.cs
Normal file
36
VDownload.Services.Utility.Network/NetworkService.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Networking.Connectivity;
|
||||
|
||||
namespace VDownload.Services.Utility.Network
|
||||
{
|
||||
public interface INetworkService
|
||||
{
|
||||
bool IsMetered { get; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class NetworkService : INetworkService
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
protected readonly IEnumerable<NetworkCostType> _notMeteredTypes = [
|
||||
NetworkCostType.Unknown,
|
||||
NetworkCostType.Unrestricted
|
||||
];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public bool IsMetered => !_notMeteredTypes.Contains(NetworkInformation.GetInternetConnectionProfile().GetConnectionCost().NetworkCostType);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22621.3233" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user