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

62 lines
2.4 KiB
C#
Raw Normal View History

2021-05-13 20:03:07 +02:00
using System;
using TINK.Model.Connector;
using TINK.Services.BluetoothLock;
using TINK.Model.Services.Geolocation;
using TINK.Model.User;
using TINK.View;
2021-06-26 20:57:55 +02:00
using TINK.Model.Device;
2021-05-13 20:03:07 +02:00
namespace TINK.ViewModel.Bikes.Bike
{
public static class BikeViewModelFactory
{
2021-06-26 20:57:55 +02:00
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
2021-05-13 20:03:07 +02:00
/// <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>
2022-01-22 18:30:23 +01:00
/// <param name="openUrlInBrowser">Delegate to open browser.</param>
2021-05-13 20:03:07 +02:00
public static BikeViewModelBase Create(
Func<bool> isConnectedDelegate,
Func<bool, IConnector> connectorFactory,
IGeolocation geolocation,
ILocksService lockService,
2021-06-26 20:57:55 +02:00
Action<string> bikeRemoveDelegate,
2021-05-13 20:03:07 +02:00
Func<IPollingUpdateTaskManager> viewUpdateManager,
2021-06-26 20:57:55 +02:00
ISmartDevice smartDevice,
2021-05-13 20:03:07 +02:00
IViewService viewService,
Model.Bike.BC.BikeInfoMutable bikeInfo,
IUser activeUser,
IInUseStateInfoProvider stateInfoProvider,
2022-01-22 18:30:23 +01:00
IBikesViewModel bikesViewModel,
Action<string> openUrlInBrowser)
2021-05-13 20:03:07 +02:00
{
return bikeInfo as Model.Bikes.Bike.BluetoothLock.IBikeInfoMutable != null
? new BluetoothLock.BikeViewModel(
isConnectedDelegate,
connectorFactory,
geolocation,
lockService,
bikeRemoveDelegate,
viewUpdateManager,
2021-06-26 20:57:55 +02:00
smartDevice,
2021-05-13 20:03:07 +02:00
viewService,
bikeInfo as Model.Bike.BluetoothLock.BikeInfoMutable,
activeUser,
stateInfoProvider,
2022-01-22 18:30:23 +01:00
bikesViewModel,
openUrlInBrowser) as BikeViewModelBase
2021-05-13 20:03:07 +02:00
: new BC.BikeViewModel(
isConnectedDelegate,
connectorFactory,
bikeRemoveDelegate,
viewUpdateManager,
2021-06-26 20:57:55 +02:00
smartDevice,
2021-05-13 20:03:07 +02:00
viewService,
bikeInfo,
activeUser,
stateInfoProvider,
2022-01-22 18:30:23 +01:00
bikesViewModel,
openUrlInBrowser);
2021-05-13 20:03:07 +02:00
}
}
}