using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ShareeBike.Services.BluetoothLock
{
/// Manages Locks services and related configuration parameter.
public class LocksServicesContainerMutable : IEnumerable
{
/// Manages the different types of LocksService objects.
private ServicesContainerMutableT LocksServices { get; }
/// Holds the name of the default locks service to use.
public static string DefaultLocksservice => typeof(BLE.LockItByScanServicePolling).FullName;
///
/// Name of active lock service implementation to use.
/// Null for production (set of lock service implentations and some fake implementation will created) hash set of services for testing purposes.
public LocksServicesContainerMutable(
string activeLockService,
HashSet locksServices)
{
LocksServices = new ServicesContainerMutableT(
locksServices,
activeLockService);
}
/// Active locks service.
public ILocksService Active => LocksServices.Active;
/// Sets a lock service as active locks service by name.
/// Name of the new locks service.
public void SetActive(string active) => LocksServices.SetActive(active);
IEnumerator IEnumerable.GetEnumerator()
=> LocksServices.Select(x => x.GetType().FullName).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> LocksServices.GetEnumerator();
public void SetTimeOut(TimeSpan connectTimeout)
{
foreach (var locksService in LocksServices)
{
locksService.TimeOut = new TimeOutProvider(new List { connectTimeout });
}
}
}
}