using System; using TINK.Model.Connector; using TINK.Model.Device; using TINK.Model.User; using TINK.View; namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler { public abstract class Base { /// /// View model to be used by subclasses for progress report and unlocking/ locking view. /// public IBikesViewModel BikesViewModel { get; set; } /// /// Gets a value indicating whether the button to reserve bike is visible or not. /// public bool IsButtonVisible { get; } /// /// Gets the name of the button when bike is disposable. /// public string ButtonText { get; } /// Provides info about the smart device (phone, tablet, ...). protected ISmartDevice SmartDevice; /// /// Reference on view service to show modal notifications and to perform navigation. /// protected IViewService ViewService { get; } /// Provides a connector object. protected Func ConnectorFactory { get; } /// Delegate to retrieve connected state. protected Func IsConnectedDelegate { get; } /// Object to manage update of view model objects from Copri. protected Func ViewUpdateManager { get; } /// Reference on the user protected IUser ActiveUser { get; } /// Bike to display. protected T SelectedBike { get; } /// Holds the is connected state. private bool isConnected; /// Gets the is connected state. public bool IsConnected { get => isConnected; set { if (value == isConnected) return; isConnected = value; } } /// Gets if the bike has to be removed after action has been completed. public bool IsRemoveBikeRequired { get; set; } /// /// Constructs the request handler base. /// /// Bike which is reserved or for which reservation is canceled. /// Provides info about the smart device (phone, tablet, ...). /// View model to be used by subclasses for progress report and unlocking/ locking view. public Base( T selectedBike, string buttonText, bool isCopriButtonVisible, Func isConnectedDelegate, Func connectorFactory, Func viewUpdateManager, ISmartDevice smartDevice, IViewService viewService, IBikesViewModel bikesViewModel, IUser activeUser) { ButtonText = buttonText; IsButtonVisible = isCopriButtonVisible; SelectedBike = selectedBike; IsConnectedDelegate = isConnectedDelegate; ConnectorFactory = connectorFactory; ViewUpdateManager = viewUpdateManager; SmartDevice = smartDevice; ViewService = viewService; ActiveUser = activeUser; IsRemoveBikeRequired = false; BikesViewModel = bikesViewModel ?? throw new ArgumentException($"Can not construct {GetType().Name}-object. {nameof(bikesViewModel)} must not be null."); } } }