1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 21:12:56 +01:00
Radarr/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);
}
}
}