From 7a0e0f77829f81fffa156035e759779200254fcd Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 17 Dec 2019 16:04:31 +0100 Subject: [PATCH] AB4227 - Moved Persistence.Factories --- .../Implement/DataTypeRepository.cs | 15 ++++++++--- src/Umbraco.Core/Umbraco.Core.csproj | 25 ------------------- .../Models/Membership/UserGroupExtensions.cs | 2 +- .../Persistence/Dtos/UserGroup2AppDto.cs | 2 +- .../Persistence/Dtos/UserGroupDto.cs | 2 +- .../Factories/AuditEntryFactory.cs | 0 .../Persistence/Factories/ConsentFactory.cs | 0 .../Factories/ContentBaseFactory.cs | 0 .../Factories/ContentTypeFactory.cs | 0 .../Persistence/Factories/DataTypeFactory.cs | 12 ++++----- .../Factories/DictionaryItemFactory.cs | 0 .../Factories/DictionaryTranslationFactory.cs | 0 .../Factories/ExternalLoginFactory.cs | 0 .../Persistence/Factories/LanguageFactory.cs | 0 .../Persistence/Factories/MacroFactory.cs | 0 .../Factories/MemberGroupFactory.cs | 0 .../Persistence/Factories/PropertyFactory.cs | 0 .../Factories/PropertyGroupFactory.cs | 0 .../Factories/PublicAccessEntryFactory.cs | 0 .../Persistence/Factories/RelationFactory.cs | 0 .../Factories/RelationTypeFactory.cs | 0 .../Factories/ServerRegistrationFactory.cs | 0 .../Persistence/Factories/TagFactory.cs | 0 .../Persistence/Factories/TemplateFactory.cs | 0 .../Persistence/Factories/UserFactory.cs | 0 .../Persistence/Factories/UserGroupFactory.cs | 0 .../Repositories/DocumentRepositoryTest.cs | 2 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 1 + 28 files changed, 22 insertions(+), 39 deletions(-) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Models/Membership/UserGroupExtensions.cs (97%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/AuditEntryFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/ConsentFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/ContentBaseFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/ContentTypeFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/DataTypeFactory.cs (91%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/DictionaryItemFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/DictionaryTranslationFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/ExternalLoginFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/LanguageFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/MacroFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/MemberGroupFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/PropertyFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/PropertyGroupFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/PublicAccessEntryFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/RelationFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/RelationTypeFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/ServerRegistrationFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/TagFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/TemplateFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/UserFactory.cs (100%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/Persistence/Factories/UserGroupFactory.cs (100%) diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs index 8e40251d6a..1f0d944c7e 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs @@ -17,6 +17,7 @@ using Umbraco.Core.Persistence.Querying; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; using Umbraco.Core.Services; +using Umbraco.Core.Strings; using static Umbraco.Core.Persistence.SqlExtensionsStatics; namespace Umbraco.Core.Persistence.Repositories.Implement @@ -28,13 +29,21 @@ namespace Umbraco.Core.Persistence.Repositories.Implement { private readonly Lazy _editors; private readonly IIOHelper _ioHelper; + private readonly Lazy _dataTypeService; + private readonly ILocalizedTextService _localizedTextService; + private readonly ILocalizationService _localizationService; + private readonly IShortStringHelper _shortStringHelper; // TODO: https://github.com/umbraco/Umbraco-CMS/issues/4237 - get rid of Lazy injection and fix circular dependencies - public DataTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, Lazy editors, ILogger logger, IIOHelper ioHelper) + public DataTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, Lazy editors, ILogger logger, IIOHelper ioHelper, Lazy dataTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper) : base(scopeAccessor, cache, logger) { _editors = editors; _ioHelper = ioHelper; + _dataTypeService = dataTypeService; + _localizedTextService = localizedTextService; + _localizationService = localizationService; + _shortStringHelper = shortStringHelper; } #region Overrides of RepositoryBase @@ -58,7 +67,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement } var dtos = Database.Fetch(dataTypeSql); - return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger,_ioHelper)).ToArray(); + return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger,_ioHelper, _dataTypeService.Value, _localizedTextService, _localizationService, _shortStringHelper)).ToArray(); } protected override IEnumerable PerformGetByQuery(IQuery query) @@ -69,7 +78,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement var dtos = Database.Fetch(sql); - return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger, _ioHelper)).ToArray(); + return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger, _ioHelper, _dataTypeService.Value, _localizedTextService, _localizationService, _shortStringHelper)).ToArray(); } #endregion diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 7b47f50a68..588e0de045 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -194,7 +194,6 @@ - @@ -205,7 +204,6 @@ - @@ -271,8 +269,6 @@ - - @@ -301,24 +297,6 @@ - - - - - - - - - - - - - - - - - - @@ -564,8 +542,5 @@ Umbraco.Infrastructure - - - \ No newline at end of file diff --git a/src/Umbraco.Core/Models/Membership/UserGroupExtensions.cs b/src/Umbraco.Infrastructure/Models/Membership/UserGroupExtensions.cs similarity index 97% rename from src/Umbraco.Core/Models/Membership/UserGroupExtensions.cs rename to src/Umbraco.Infrastructure/Models/Membership/UserGroupExtensions.cs index b1d0189c56..93c82367d7 100644 --- a/src/Umbraco.Core/Models/Membership/UserGroupExtensions.cs +++ b/src/Umbraco.Infrastructure/Models/Membership/UserGroupExtensions.cs @@ -3,7 +3,7 @@ using Umbraco.Core.Persistence.Dtos; namespace Umbraco.Core.Models.Membership { - internal static class UserGroupExtensions + public static class UserGroupExtensions { public static IReadOnlyUserGroup ToReadOnlyGroup(this IUserGroup group) { diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroup2AppDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroup2AppDto.cs index c0ac48b1c5..03ba93fe59 100644 --- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroup2AppDto.cs +++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroup2AppDto.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.Persistence.Dtos { [TableName(Constants.DatabaseSchema.Tables.UserGroup2App)] [ExplicitColumns] - internal class UserGroup2AppDto + public class UserGroup2AppDto { [Column("userGroupId")] [PrimaryKeyColumn(AutoIncrement = false, Name = "PK_userGroup2App", OnColumns = "userGroupId, app")] diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs index 3383ed9e3d..0735912c8f 100644 --- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs +++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Persistence.Dtos [TableName(Constants.DatabaseSchema.Tables.UserGroup)] [PrimaryKey("id")] [ExplicitColumns] - internal class UserGroupDto + public class UserGroupDto { public UserGroupDto() { diff --git a/src/Umbraco.Core/Persistence/Factories/AuditEntryFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/AuditEntryFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/AuditEntryFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/AuditEntryFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/ConsentFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ConsentFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/ConsentFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/ConsentFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/ContentTypeFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ContentTypeFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/ContentTypeFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/ContentTypeFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/DataTypeFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/DataTypeFactory.cs similarity index 91% rename from src/Umbraco.Core/Persistence/Factories/DataTypeFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/DataTypeFactory.cs index 84cd641ce5..04609b2821 100644 --- a/src/Umbraco.Core/Persistence/Factories/DataTypeFactory.cs +++ b/src/Umbraco.Infrastructure/Persistence/Factories/DataTypeFactory.cs @@ -1,27 +1,25 @@ using System; -using System.Reflection; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using Umbraco.Composing; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.PropertyEditors; -using Current = Umbraco.Core.Composing.Current; +using Umbraco.Core.Services; +using Umbraco.Core.Strings; + namespace Umbraco.Core.Persistence.Factories { internal static class DataTypeFactory { - public static IDataType BuildEntity(DataTypeDto dto, PropertyEditorCollection editors, ILogger logger, IIOHelper ioHelper) + public static IDataType BuildEntity(DataTypeDto dto, PropertyEditorCollection editors, ILogger logger, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper) { if (!editors.TryGet(dto.EditorAlias, out var editor)) { logger.Warn(typeof(DataType), "Could not find an editor with alias {EditorAlias}, treating as Label." +" The site may fail to boot and / or load data types and run.", dto.EditorAlias); //convert to label - editor = new LabelPropertyEditor(logger, ioHelper, Current.Services.DataTypeService, Current.Services.TextService, Current.Services.LocalizationService, Current.ShortStringHelper); + editor = new LabelPropertyEditor(logger, ioHelper,dataTypeService , localizedTextService, localizationService, shortStringHelper); } var dataType = new DataType(editor); diff --git a/src/Umbraco.Core/Persistence/Factories/DictionaryItemFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/DictionaryItemFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/DictionaryItemFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/DictionaryItemFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/DictionaryTranslationFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/DictionaryTranslationFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/DictionaryTranslationFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/DictionaryTranslationFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/ExternalLoginFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ExternalLoginFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/ExternalLoginFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/ExternalLoginFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/LanguageFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/LanguageFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/LanguageFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/LanguageFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/MacroFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/MacroFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/MacroFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/MacroFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/MemberGroupFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/MemberGroupFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/MemberGroupFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/MemberGroupFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/PublicAccessEntryFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PublicAccessEntryFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/PublicAccessEntryFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/PublicAccessEntryFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/RelationFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/RelationFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/RelationFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/RelationFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/RelationTypeFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/RelationTypeFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/RelationTypeFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/RelationTypeFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/ServerRegistrationFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ServerRegistrationFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/ServerRegistrationFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/ServerRegistrationFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/TagFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/TagFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/TagFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/TagFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/TemplateFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/TemplateFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/UserFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/UserFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs diff --git a/src/Umbraco.Core/Persistence/Factories/UserGroupFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/UserGroupFactory.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Factories/UserGroupFactory.cs rename to src/Umbraco.Infrastructure/Persistence/Factories/UserGroupFactory.cs diff --git a/src/Umbraco.Tests/Persistence/Repositories/DocumentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DocumentRepositoryTest.cs index b7ae1604c5..5c97bdf034 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DocumentRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DocumentRepositoryTest.cs @@ -50,7 +50,7 @@ namespace Umbraco.Tests.Persistence.Repositories TemplateRepository tr; var ctRepository = CreateRepository(scopeAccessor, out contentTypeRepository, out tr); var editors = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty())); - dtdRepository = new DataTypeRepository(scopeAccessor, appCaches, new Lazy(() => editors), Logger, TestHelper.IOHelper); + dtdRepository = new DataTypeRepository(scopeAccessor, appCaches, new Lazy(() => editors), Logger, IOHelper, new Lazy(() => DataTypeService), LocalizedTextService, LocalizationService, ShortStringHelper); return ctRepository; } diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 8b6553ff80..5afd937f84 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -51,6 +51,7 @@ using FileSystems = Umbraco.Core.IO.FileSystems; using Umbraco.Web.Templates; using Umbraco.Web.PropertyEditors; using Umbraco.Core.Dictionary; +using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Services; using Umbraco.Net;