1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Core/Datastore/SqlCeProxy.cs
2013-02-16 15:29:21 -08:00

33 lines
969 B
C#

using System;
using System.Data.Common;
using System.Linq;
using System.Reflection;
namespace NzbDrone.Core.Datastore
{
public static class SqlCeProxy
{
private static readonly object instance;
private static readonly Type proxyType;
static SqlCeProxy()
{
proxyType = Assembly.Load("NzbDrone.SqlCe").GetExportedTypes()[0];
instance = Activator.CreateInstance(proxyType);
}
public static DbConnection EnsureDatabase(string connectionString)
{
var factoryMethod = proxyType.GetMethod("EnsureDatabase");
return (DbConnection)factoryMethod.Invoke(instance, new object[] { connectionString });
}
public static DbProviderFactory GetSqlCeProviderFactory()
{
var factoryMethod = proxyType.GetMethod("GetSqlCeProviderFactory");
return (DbProviderFactory)factoryMethod.Invoke(instance, null);
}
}
}