From f668c25346f98fb2cd8034ce6090f717b6e5aa26 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 11 Jul 2017 19:41:28 +0200 Subject: [PATCH] Cleanup --- src/Umbraco.Core/Persistence/SqlContext.cs | 12 ++++-------- .../Persistence/UmbracoDatabaseFactory.cs | 2 +- src/Umbraco.Core/Scoping/ScopeProvider.cs | 3 --- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Core/Persistence/SqlContext.cs b/src/Umbraco.Core/Persistence/SqlContext.cs index 93f2f41da7..d7628576dc 100644 --- a/src/Umbraco.Core/Persistence/SqlContext.cs +++ b/src/Umbraco.Core/Persistence/SqlContext.cs @@ -10,17 +10,13 @@ namespace Umbraco.Core.Persistence { public SqlContext(ISqlSyntaxProvider sqlSyntax, IPocoDataFactory pocoDataFactory, DatabaseType databaseType, IMapperCollection mappers = null) { - if (sqlSyntax == null) throw new ArgumentNullException(nameof(sqlSyntax)); - if (pocoDataFactory == null) throw new ArgumentNullException(nameof(pocoDataFactory)); - if (databaseType == null) throw new ArgumentNullException(nameof(databaseType)); - // for tests if (mappers == null) mappers = new Mappers.MapperCollection(Enumerable.Empty()); - - SqlSyntax = sqlSyntax; - PocoDataFactory = pocoDataFactory; - DatabaseType = databaseType; Mappers = mappers; + + SqlSyntax = sqlSyntax ?? throw new ArgumentNullException(nameof(sqlSyntax)); + PocoDataFactory = pocoDataFactory ?? throw new ArgumentNullException(nameof(pocoDataFactory)); + DatabaseType = databaseType ?? throw new ArgumentNullException(nameof(databaseType)); } public ISqlSyntaxProvider SqlSyntax { get; } diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs index 711ae5fcca..e986bea239 100644 --- a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs +++ b/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs @@ -192,7 +192,7 @@ namespace Umbraco.Core.Persistence // these are created here because it is the UmbracoDatabaseFactory that determines // the sql syntax, poco data factory, and database type - so it "owns" the context // and the query factory - _sqlContext = new SqlContext(_sqlSyntax, _pocoDataFactory, _databaseType, _mappers); + _sqlContext = new SqlContext(_sqlSyntax, _pocoDataFactory, _databaseType, _mappers); _logger.Debug("Configured."); Configured = true; diff --git a/src/Umbraco.Core/Scoping/ScopeProvider.cs b/src/Umbraco.Core/Scoping/ScopeProvider.cs index 6707281fb6..dc4f7f7152 100644 --- a/src/Umbraco.Core/Scoping/ScopeProvider.cs +++ b/src/Umbraco.Core/Scoping/ScopeProvider.cs @@ -80,9 +80,6 @@ namespace Umbraco.Core.Scoping // and we can retrieve the actual objects from the table. // only issue: how are we supposed to clear the table? we can't, really. objects should take // care of de-registering themselves from context. - // everything we use does, except the NoScope scope, which just stays there - // - // during tests, NoScope can to into call context... nothing much we can do about it private static readonly object StaticCallContextObjectsLock = new object(); private static readonly Dictionary StaticCallContextObjects