sharee.bike-App/TINKLib/ViewModel/Bikes/Bike/BikeViewModelFactory.cs

69 lines
2 KiB
C#
Raw Normal View History

2023-04-05 15:02:10 +02:00
using System;
2021-05-13 20:03:07 +02:00
using TINK.Model.Connector;
2022-08-30 15:42:25 +02:00
using TINK.Model.Device;
using TINK.Model.User;
2021-05-13 20:03:07 +02:00
using TINK.Services.BluetoothLock;
2022-04-10 17:38:34 +02:00
using TINK.Services.Geolocation;
2021-05-13 20:03:07 +02:00
using TINK.View;
namespace TINK.ViewModel.Bikes.Bike
{
2022-09-06 16:08:19 +02:00
public static class BikeViewModelFactory
{
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
/// <param name="stateInfoProvider">Provides in use state information.</param>
/// <param name="bikesViewModel">View model to be used for progress report and unlocking/ locking view.</param>
/// <param name="openUrlInBrowser">Delegate to open browser.</param>
public static BikeViewModelBase Create(
Func<bool> isConnectedDelegate,
Func<bool, IConnector> connectorFactory,
2023-04-05 15:02:10 +02:00
IGeolocationService geolocationService,
2022-09-06 16:08:19 +02:00
ILocksService lockService,
Action<string> bikeRemoveDelegate,
Func<IPollingUpdateTaskManager> viewUpdateManager,
ISmartDevice smartDevice,
IViewService viewService,
Model.Bikes.BikeInfoNS.BC.BikeInfoMutable bikeInfo,
IUser activeUser,
IInUseStateInfoProvider stateInfoProvider,
IBikesViewModel bikesViewModel,
Action<string> openUrlInBrowser)
{
if (bikeInfo is Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable)
{
return new BluetoothLock.BikeViewModel(
isConnectedDelegate,
connectorFactory,
2023-04-05 15:02:10 +02:00
geolocationService,
2022-09-06 16:08:19 +02:00
lockService,
bikeRemoveDelegate,
viewUpdateManager,
smartDevice,
viewService,
bikeInfo as Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable,
activeUser,
stateInfoProvider,
bikesViewModel,
openUrlInBrowser);
}
if (bikeInfo is Model.Bikes.BikeInfoNS.CopriLock.BikeInfoMutable)
{
return new CopriLock.BikeViewModel(
isConnectedDelegate,
connectorFactory,
bikeRemoveDelegate,
viewUpdateManager,
smartDevice,
viewService,
bikeInfo,
activeUser,
stateInfoProvider,
bikesViewModel,
openUrlInBrowser);
}
2022-04-25 22:15:15 +02:00
2022-09-06 16:08:19 +02:00
return null;
}
}
2021-05-13 20:03:07 +02:00
}