diff --git a/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj b/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj
index 604cbd2592..f4a39df579 100644
--- a/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj
+++ b/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj
@@ -49,13 +49,11 @@
..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.dll
- False
- False
+ True
..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.Entity.dll
- False
- False
+ True
diff --git a/src/SQLCE4Umbraco/SqlCeApplicationBlock.cs b/src/SQLCE4Umbraco/SqlCeApplicationBlock.cs
index fd778bbfb3..2dd0f26e90 100644
--- a/src/SQLCE4Umbraco/SqlCeApplicationBlock.cs
+++ b/src/SQLCE4Umbraco/SqlCeApplicationBlock.cs
@@ -240,7 +240,7 @@ namespace SqlCE4Umbraco
{
var cmd = trx == null ? new SqlCeCommand(commandText, conn) : new SqlCeCommand(commandText, conn, trx);
AttachParameters(cmd, commandParameters);
- return cmd.ExecuteReader(CommandBehavior.CloseConnection);
+ return cmd.ExecuteReader();
}
catch
{
diff --git a/src/SQLCE4Umbraco/app.config b/src/SQLCE4Umbraco/app.config
index cb532bd57a..1ac57258d3 100644
--- a/src/SQLCE4Umbraco/app.config
+++ b/src/SQLCE4Umbraco/app.config
@@ -4,7 +4,7 @@
-
+
@@ -32,4 +32,7 @@
-
+
+
+
+
diff --git a/src/Umbraco.Compat7/Core/ApplicationContext.cs b/src/Umbraco.Compat7/Core/ApplicationContext.cs
index 40c295c190..cf423ce1a5 100644
--- a/src/Umbraco.Compat7/Core/ApplicationContext.cs
+++ b/src/Umbraco.Compat7/Core/ApplicationContext.cs
@@ -1,6 +1,7 @@
using System;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
+using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
// ReSharper disable once CheckNamespace
@@ -10,7 +11,7 @@ namespace Umbraco.Core
{
private ApplicationContext()
{
- DatabaseContext = new DatabaseContext(DI.Current.DatabaseFactory);
+ DatabaseContext = new DatabaseContext(DI.Current.Container.GetInstance());
}
public static ApplicationContext Current { get; } = new ApplicationContext();
diff --git a/src/Umbraco.Compat7/Core/DatabaseContext.cs b/src/Umbraco.Compat7/Core/DatabaseContext.cs
index 9048006675..9c02cbac1d 100644
--- a/src/Umbraco.Compat7/Core/DatabaseContext.cs
+++ b/src/Umbraco.Compat7/Core/DatabaseContext.cs
@@ -21,9 +21,7 @@ namespace Umbraco.Core
/// used.
public DatabaseContext(IUmbracoDatabaseFactory databaseFactory)
{
- if (databaseFactory == null) throw new ArgumentNullException(nameof(databaseFactory));
-
- _databaseFactory = databaseFactory;
+ _databaseFactory = databaseFactory ?? throw new ArgumentNullException(nameof(databaseFactory));
}
///
@@ -50,16 +48,7 @@ namespace Umbraco.Core
/// Gets an ambient database for doing CRUD operations against custom tables that resides in the Umbraco database.
///
/// Should not be used for operation against standard Umbraco tables; as services should be used instead.
- public IUmbracoDatabase Database => _databaseFactory.GetDatabase();
-
- ///
- /// Gets an ambient database scope.
- ///
- /// A disposable object representing the scope.
- public IDisposable CreateDatabaseScope() // fixme - move over to factory
- {
- return _databaseFactory.CreateScope();
- }
+ public IUmbracoDatabase Database => throw new NotImplementedException(); // there's no magic?
///
/// Gets a value indicating whether the database is configured.
diff --git a/src/Umbraco.Core/BindingRedirects.cs b/src/Umbraco.Core/BindingRedirects.cs
new file mode 100644
index 0000000000..4fadb4db70
--- /dev/null
+++ b/src/Umbraco.Core/BindingRedirects.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using System.Web;
+using Umbraco.Core;
+
+[assembly: PreApplicationStartMethod(typeof(BindingRedirects), "Initialize")]
+
+namespace Umbraco.Core
+{
+ ///
+ /// Manages any assembly binding redirects that cannot be done via config (i.e. unsigned --> signed assemblies)
+ ///
+ public sealed class BindingRedirects
+ {
+ public static void Initialize()
+ {
+ // this only gets called when an assembly can't be resolved
+ AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
+ }
+
+ private static readonly Regex Log4NetAssemblyPattern = new Regex("log4net, Version=([\\d\\.]+?), Culture=neutral, PublicKeyToken=\\w+$", RegexOptions.Compiled);
+ private const string Log4NetReplacement = "log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a";
+
+ ///
+ /// This is used to do an assembly binding redirect via code - normally required due to signature changes in assemblies
+ ///
+ ///
+ ///
+ ///
+ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+ {
+ //log4net:
+ if (Log4NetAssemblyPattern.IsMatch(args.Name) && args.Name != Log4NetReplacement)
+ {
+ return Assembly.Load(Log4NetAssemblyPattern.Replace(args.Name, Log4NetReplacement));
+ }
+
+ //AutoMapper:
+ // ensure the assembly is indeed AutoMapper and that the PublicKeyToken is null before trying to Load again
+ // do NOT just replace this with 'return Assembly', as it will cause an infinite loop -> stackoverflow
+ if (args.Name.StartsWith("AutoMapper") && args.Name.EndsWith("PublicKeyToken=null"))
+ return Assembly.Load(args.Name.Replace(", PublicKeyToken=null", ", PublicKeyToken=be96cd2c38ef1005"));
+
+ return null;
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Cache/CacheHelper.cs b/src/Umbraco.Core/Cache/CacheHelper.cs
index cbf2836232..157cedb3eb 100644
--- a/src/Umbraco.Core/Cache/CacheHelper.cs
+++ b/src/Umbraco.Core/Cache/CacheHelper.cs
@@ -14,8 +14,11 @@ namespace Umbraco.Core.Cache
private static readonly ICacheProvider NullRequestCache = new NullCacheProvider();
private static readonly ICacheProvider NullStaticCache = new NullCacheProvider();
private static readonly IRuntimeCacheProvider NullRuntimeCache = new NullCacheProvider();
-
- ///
+ private static readonly IsolatedRuntimeCache NullIsolatedCache = new IsolatedRuntimeCache(_ => NullRuntimeCache);
+
+ public static CacheHelper NoCache { get; } = new CacheHelper(NullRuntimeCache, NullStaticCache, NullRequestCache, NullIsolatedCache);
+
+ ///
/// Creates a cache helper with disabled caches
///
///
@@ -24,7 +27,10 @@ namespace Umbraco.Core.Cache
///
public static CacheHelper CreateDisabledCacheHelper()
{
- return new CacheHelper(NullRuntimeCache, NullStaticCache, NullRequestCache, new IsolatedRuntimeCache(t => NullRuntimeCache));
+ // do *not* return NoCache
+ // NoCache is a special instance that is detected by RepositoryBase and disables all cache policies
+ // CreateDisabledCacheHelper is used in tests to use no cache, *but* keep all cache policies
+ return new CacheHelper(NullRuntimeCache, NullStaticCache, NullRequestCache, NullIsolatedCache);
}
///
diff --git a/src/Umbraco.Core/Cache/CacheKeys.cs b/src/Umbraco.Core/Cache/CacheKeys.cs
index 92f8529bbe..d0155ae520 100644
--- a/src/Umbraco.Core/Cache/CacheKeys.cs
+++ b/src/Umbraco.Core/Cache/CacheKeys.cs
@@ -60,8 +60,8 @@ namespace Umbraco.Core.Cache
[UmbracoWillObsolete("This cache key is only used for legacy business logic caching, remove in v8")]
public const string ContentTypePropertiesCacheKey = "ContentType_PropertyTypes_Content:";
-
- [UmbracoWillObsolete("This cache key is only used for legacy business logic caching, remove in v8")]
+
+ [Obsolete("No longer used and will be removed in v8")]
public const string PropertyTypeCacheKey = "UmbracoPropertyTypeCache";
[Obsolete("This is no longer used and will be removed from the codebase in the future")]
diff --git a/src/Umbraco.Core/Cache/DeepCloneRuntimeCacheProvider.cs b/src/Umbraco.Core/Cache/DeepCloneRuntimeCacheProvider.cs
index 0ae721943d..456c2955f0 100644
--- a/src/Umbraco.Core/Cache/DeepCloneRuntimeCacheProvider.cs
+++ b/src/Umbraco.Core/Cache/DeepCloneRuntimeCacheProvider.cs
@@ -22,14 +22,20 @@ namespace Umbraco.Core.Cache
///
internal class DeepCloneRuntimeCacheProvider : IRuntimeCacheProvider, IRuntimeCacheProviderWrapper
{
- public IRuntimeCacheProvider InnerProvider { get; private set; }
+ public IRuntimeCacheProvider InnerProvider { get; }
public DeepCloneRuntimeCacheProvider(IRuntimeCacheProvider innerProvider)
{
+ var type = typeof (DeepCloneRuntimeCacheProvider);
+
+ if (innerProvider.GetType() == type)
+ throw new InvalidOperationException($"A {type} cannot wrap another instance of {type}.");
+
InnerProvider = innerProvider;
}
#region Clear - doesn't require any changes
+
public void ClearAllCache()
{
InnerProvider.ClearAllCache();
@@ -63,7 +69,8 @@ namespace Umbraco.Core.Cache
public void ClearCacheByKeyExpression(string regexString)
{
InnerProvider.ClearCacheByKeyExpression(regexString);
- }
+ }
+
#endregion
public IEnumerable