using System; using ShareeBike.Model.Device; using ShareeBike.Repository; namespace ShareeBike.Model.Connector { public class ConnectorFactory { /// /// Gets a connector object depending on whether beein onlin or offline. /// /// /// True if online, false if offline. /// If offline cache connector is returned to avoid performance penalty which would happen when trying to communicate with backend in offline scenario. /// /// Provides app related info (app name and version, merchantid) to pass to COPRI. /// Two letter ISO language name. /// Holds info about smart device. public static IConnector Create( bool isConnected, Uri activeUri, AppContextInfo appContextInfo, string uiIsoLangugageName, string sessionCookie, string mail, ISmartDevice smartDevice = null, TimeSpan? expiresAfter = null) { return isConnected ? new Connector(activeUri, appContextInfo, uiIsoLangugageName, sessionCookie, mail, smartDevice, expiresAfter: expiresAfter) as IConnector : new ConnectorCache(appContextInfo, uiIsoLangugageName, sessionCookie, mail, smartDevice); } } }