Sonarr/NzbDrone.Core/Datastore/ObjectDbFactory.cs

43 lines
1.1 KiB
C#
Raw Normal View History

using System.Linq;
2013-02-17 01:52:40 +00:00
using NzbDrone.Common;
using Sqo;
namespace NzbDrone.Core.Datastore
{
public interface IObjectDbFactory
{
IObjectDatabase Create(string dbPath = null);
2013-02-17 01:52:40 +00:00
}
public class SiaqoDbFactory : IObjectDbFactory
{
private readonly DiskProvider _diskProvider;
private readonly EnvironmentProvider _environmentProvider;
2013-02-17 01:52:40 +00:00
public SiaqoDbFactory(DiskProvider diskProvider, EnvironmentProvider environmentProvider)
2013-02-17 01:52:40 +00:00
{
_diskProvider = diskProvider;
_environmentProvider = environmentProvider;
2013-02-17 01:52:40 +00:00
}
public IObjectDatabase Create(string dbPath = null)
2013-02-17 01:52:40 +00:00
{
if (string.IsNullOrWhiteSpace(dbPath))
{
dbPath = _environmentProvider.GetObjectDbFolder();
}
2013-02-17 01:52:40 +00:00
if (!_diskProvider.FolderExists(dbPath))
2013-02-17 01:52:40 +00:00
{
_diskProvider.CreateDirectory(dbPath);
}
SiaqodbConfigurator.SetTrialLicense("uvhpW4hT5Rtq+Uoyq8MOm1Smon15foxV5iS5bAegIXU=");
var db = new Siaqodb(dbPath);
return new SiaqodbProxy(db);
}
}
}