sharee.bike-App/TINKLib/Model/Connector/ConnectorFactory.cs

30 lines
1.2 KiB
C#
Raw Normal View History

2021-05-13 20:03:07 +02:00
using System;
2022-01-04 18:54:03 +01:00
using TINK.Repository;
2021-05-13 20:03:07 +02:00
namespace TINK.Model.Connector
{
public class ConnectorFactory
{
/// <summary>
/// Gets a connector object depending on whether beein onlin or offline.
/// </summary>
2022-01-04 18:54:03 +01:00
/// <param name="isConnected">True if online, false if offline. If offline cache connector is returned.</param>
/// <param name="appContextInfo">Provides app related info (app name and version, merchantid) to pass to COPRI.</param>
2022-08-30 15:42:25 +02:00
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
2021-05-13 20:03:07 +02:00
/// <returns></returns>
2022-01-04 18:54:03 +01:00
public static IConnector Create(
2022-08-30 15:42:25 +02:00
bool isConnected,
2022-01-04 18:54:03 +01:00
Uri activeUri,
2022-08-30 15:42:25 +02:00
AppContextInfo appContextInfo,
string uiIsoLangugageName,
string sessionCookie,
string mail,
2022-01-04 18:54:03 +01:00
TimeSpan? expiresAfter = null)
2021-05-13 20:03:07 +02:00
{
return isConnected
2022-08-30 15:42:25 +02:00
? new Connector(activeUri, appContextInfo, uiIsoLangugageName, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector
: new ConnectorCache(appContextInfo, uiIsoLangugageName, sessionCookie, mail);
2021-05-13 20:03:07 +02:00
}
}
}