using System; using ShareeBike.Model.Connector; using ShareeBike.Model.Device; using ShareeBike.Model.User; using ShareeBike.Services.BluetoothLock; using ShareeBike.Services.Geolocation; using ShareeBike.View; namespace ShareeBike.ViewModel.Bikes.Bike { public static class BikeViewModelFactory { /// Provides info about the smart device (phone, tablet, ...). /// Holds the view context in which bike view model is used. /// Provides in use state information. /// View model to be used for progress report and unlocking/ locking view. /// Delegate to open browser. public static BikeViewModelBase Create( Func isConnectedDelegate, Func connectorFactory, IGeolocationService geolocationService, ILocksService lockService, Action bikeRemoveDelegate, Func viewUpdateManager, ISmartDevice smartDevice, IViewService viewService, Model.Bikes.BikeInfoNS.BC.BikeInfoMutable bikeInfo, IUser activeUser, ViewContext viewContext, IInUseStateInfoProvider stateInfoProvider, IBikesViewModel bikesViewModel, Action openUrlInBrowser) { if (bikeInfo is Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable) { return new BluetoothLock.BikeViewModel( isConnectedDelegate, connectorFactory, geolocationService, lockService, bikeRemoveDelegate, viewUpdateManager, smartDevice, viewService, bikeInfo as Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable, activeUser, viewContext, stateInfoProvider, bikesViewModel, openUrlInBrowser); } if (bikeInfo is Model.Bikes.BikeInfoNS.CopriLock.BikeInfoMutable) { return new CopriLock.BikeViewModel( isConnectedDelegate, connectorFactory, bikeRemoveDelegate, viewUpdateManager, smartDevice, viewService, bikeInfo, activeUser, viewContext, stateInfoProvider, bikesViewModel, openUrlInBrowser); } return null; } } }