sharee.bike-App/TINKLib/Services/Geolocation/SimulatedGeolocationService.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2023-04-05 15:02:10 +02:00
using System;
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
{
2023-04-05 15:02:10 +02:00
public class SimulatedGeolocationService : IGeolocationService
2022-09-06 16:08:19 +02:00
{
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>
2023-04-19 12:14:14 +02:00
/// <param name="timeStamp">Time when geolocation is of interest. Is used to determine whether cached geolocation can be used or not.</param>
2023-04-05 15:02:10 +02:00
public async Task<IGeolocation> GetAsync(CancellationToken? cancelToken = null, DateTime? timeStamp = null)
2022-09-06 16:08:19 +02:00
{
2023-04-05 15:02:10 +02:00
return await Task.FromResult(new Geolocation.Builder {
Latitude = 47.976634,
Longitude = 7.825490,
Accuracy = 0,
Timestamp = timeStamp ?? DateTime.Now }.Build()); ;
2022-09-06 16:08:19 +02:00
}
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
}