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

28 lines
1,023 B
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>
2021-05-13 20:03:07 +02:00
/// <returns></returns>
2022-01-04 18:54:03 +01:00
public static IConnector Create(
bool isConnected,
Uri activeUri,
AppContextInfo appContextInfo,
string sessionCookie,
string mail,
TimeSpan? expiresAfter = null)
2021-05-13 20:03:07 +02:00
{
return isConnected
2022-01-04 18:54:03 +01:00
? new Connector(activeUri, appContextInfo, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector
2022-01-04 18:59:16 +01:00
: new ConnectorCache(appContextInfo, sessionCookie, mail);
2021-05-13 20:03:07 +02:00
}
}
}