sonarr-repo-only/NzbDrone.Core/Datastore/EloqueraDbFactory.cs

32 lines
863 B
C#
Raw Normal View History

2013-02-03 22:01:36 +00:00
using System;
using System.IO;
using System.Linq;
using Eloquera.Client;
namespace NzbDrone.Core.Datastore
{
public class EloqueraDbFactory
{
2013-02-04 00:10:15 +00:00
public EloqueraDb CreateMemoryDb()
2013-02-03 22:01:36 +00:00
{
2013-02-04 00:10:15 +00:00
return InternalCreate("server=(local);password=;options=inmemory;",Guid.NewGuid().ToString());
2013-02-03 22:01:36 +00:00
}
2013-02-04 00:10:15 +00:00
public EloqueraDb Create(string dbPath)
2013-02-03 22:01:36 +00:00
{
2013-02-04 00:10:15 +00:00
var file = new FileInfo(dbPath).Name;
return InternalCreate(string.Format("server=(local);database={0};usedatapath={1};password=;", file, dbPath),file);
}
2013-02-03 22:01:36 +00:00
2013-02-04 00:10:15 +00:00
private EloqueraDb InternalCreate(string connectionString, string databaseName)
{
var db = new DB(connectionString);
db.CreateDatabase(databaseName);
db.OpenDatabase(databaseName);
2013-02-03 22:01:36 +00:00
return new EloqueraDb(db);
}
2013-02-04 00:10:15 +00:00
2013-02-03 22:01:36 +00:00
}
}