replaced compile time with runtime mono check.

This commit is contained in:
kay.one 2013-02-16 14:24:58 -08:00
commit 2873fc9f6d
7 changed files with 35 additions and 30 deletions

View file

@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data.Common;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Reflection;
using NLog;
using NzbDrone.Common;
@ -21,22 +19,19 @@ namespace NzbDrone.Core.Datastore
{
Database.Mapper = new CustomeMapper();
#if __MonoCS__
#else
if (EnvironmentProvider.IsMono) return;
var dataSet = (System.Data.DataSet)ConfigurationManager.GetSection("system.data");
dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0"
, "System.Data.SqlServerCe.4.0"
, ".NET Framework Data Provider for Microsoft SQL Server Compact"
, "System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
, "System.Data.SqlServerCe.4.0"
, ".NET Framework Data Provider for Microsoft SQL Server Compact"
,
"System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
var proxyType = Assembly.Load("NzbDrone.SqlCe").GetExportedTypes()[0];
var instance = Activator.CreateInstance(proxyType);
var factoryMethod = proxyType.GetMethod("GetSqlCeProviderFactory");
_factory = (DbProviderFactory)factoryMethod.Invoke(instance, null);
#endif
}
@ -83,9 +78,10 @@ namespace NzbDrone.Core.Datastore
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
{
#if __MonoCS__
throw new NotSupportedException("SqlCe is not supported in mono");
#endif
if (EnvironmentProvider.IsMono)
{
throw new NotSupportedException("SqlCe is not supported in mono");
}
lock (initilized)
{