2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
2021-08-28 10:04:10 +02:00
|
|
|
|
using System.Threading;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using TINK.Model.Device;
|
|
|
|
|
using Xamarin.Essentials;
|
|
|
|
|
|
2022-04-10 17:38:34 +02:00
|
|
|
|
namespace TINK.Services.Geolocation
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public class SimulatedGeolocationService : IGeolocation
|
|
|
|
|
{
|
|
|
|
|
private IGeolodationDependent Dependent { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public SimulatedGeolocationService(IGeolodationDependent dependent)
|
|
|
|
|
{
|
|
|
|
|
Dependent = dependent;
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary> Gets the current location.</summary>
|
|
|
|
|
/// <param name="cancelToken">Token to cancel request for geolocation.</param>
|
|
|
|
|
/// <param name="timeStamp">Time when geolocation is of interest. Is used to determine whether cached geoloation can be used or not.</param>
|
|
|
|
|
public async Task<Location> GetAsync(CancellationToken? cancelToken = null, DateTime? timeStamp = null)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(new Location(47.976634, 7.825490) { Accuracy = 0, Timestamp = timeStamp ?? DateTime.Now }); ;
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary> If true location data returned is simulated.</summary>
|
|
|
|
|
public bool IsSimulation { get => true; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public bool IsGeolcationEnabled => Dependent.IsGeolcationEnabled;
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|