AB4227 - Moved Persistence.Factories

This commit is contained in:
Bjarke Berg
2019-12-17 16:04:31 +01:00
parent 7c1e81db0d
commit 7a0e0f7782
28 changed files with 22 additions and 39 deletions

View File

@@ -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<PropertyEditorCollection> _editors;
private readonly IIOHelper _ioHelper;
private readonly Lazy<IDataTypeService> _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<PropertyEditorCollection> editors, ILogger logger, IIOHelper ioHelper)
public DataTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, Lazy<PropertyEditorCollection> editors, ILogger logger, IIOHelper ioHelper, Lazy<IDataTypeService> 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<int,DataTypeDefinition>
@@ -58,7 +67,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
}
var dtos = Database.Fetch<DataTypeDto>(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<IDataType> PerformGetByQuery(IQuery<IDataType> query)
@@ -69,7 +78,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var dtos = Database.Fetch<DataTypeDto>(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

View File

@@ -194,7 +194,6 @@
<Compile Include="Models\Identity\IdentityMapDefinition.cs" />
<Compile Include="Models\Identity\IdentityUser.cs" />
<Compile Include="Models\Identity\UserLoginInfoWrapper.cs" />
<Compile Include="Models\Membership\UserGroupExtensions.cs" />
<Compile Include="Models\PathValidationExtensions.cs" />
<Compile Include="Models\UserExtensions.cs" />
<Compile Include="Packaging\PackageDataInstallation.cs" />
@@ -205,7 +204,6 @@
<Compile Include="PropertyEditors\DataValueReferenceFactoryCollectionBuilder.cs" />
<Compile Include="PropertyEditors\IDataValueReference.cs" />
<Compile Include="PropertyEditors\IDataValueReferenceFactory.cs" />
<Compile Include="Persistence\Factories\MacroFactory.cs" />
<Compile Include="Persistence\Repositories\Implement\ContentTypeCommonRepository.cs" />
<Compile Include="Persistence\Repositories\IContentTypeCommonRepository.cs" />
<Compile Include="Persistence\Repositories\Implement\LanguageRepositoryExtensions.cs" />
@@ -271,8 +269,6 @@
<Compile Include="Migrations\Upgrade\V_8_0_0\UpdatePickerIntegerValuesToUdi.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\UserForeignKeys.cs" />
<Compile Include="Migrations\Upgrade\Common\CreateKeysAndIndexes.cs" />
<Compile Include="Persistence\Factories\AuditEntryFactory.cs" />
<Compile Include="Persistence\Factories\ConsentFactory.cs" />
<Compile Include="Persistence\Repositories\Implement\AuditEntryRepository.cs" />
<Compile Include="Persistence\Repositories\Implement\ConsentRepository.cs" />
<Compile Include="RuntimeOptions.cs" />
@@ -301,24 +297,6 @@
<Compile Include="Persistence\DatabaseDebugHelper.cs" />
<Compile Include="Persistence\DbCommandExtensions.cs" />
<Compile Include="Persistence\EntityNotFoundException.cs" />
<Compile Include="Persistence\Factories\ContentTypeFactory.cs" />
<Compile Include="Persistence\Factories\DataTypeFactory.cs" />
<Compile Include="Persistence\Factories\DictionaryItemFactory.cs" />
<Compile Include="Persistence\Factories\DictionaryTranslationFactory.cs" />
<Compile Include="Persistence\Factories\ExternalLoginFactory.cs" />
<Compile Include="Persistence\Factories\LanguageFactory.cs" />
<Compile Include="Persistence\Factories\ContentBaseFactory.cs" />
<Compile Include="Persistence\Factories\MemberGroupFactory.cs" />
<Compile Include="Persistence\Factories\PropertyFactory.cs" />
<Compile Include="Persistence\Factories\PropertyGroupFactory.cs" />
<Compile Include="Persistence\Factories\PublicAccessEntryFactory.cs" />
<Compile Include="Persistence\Factories\RelationFactory.cs" />
<Compile Include="Persistence\Factories\RelationTypeFactory.cs" />
<Compile Include="Persistence\Factories\ServerRegistrationFactory.cs" />
<Compile Include="Persistence\Factories\TagFactory.cs" />
<Compile Include="Persistence\Factories\TemplateFactory.cs" />
<Compile Include="Persistence\Factories\UserFactory.cs" />
<Compile Include="Persistence\Factories\UserGroupFactory.cs" />
<Compile Include="Persistence\LocalDb.cs" />
<Compile Include="Migrations\IMigrationContext.cs" />
<Compile Include="Migrations\IMigrationExpression.cs" />
@@ -564,8 +542,5 @@
<Name>Umbraco.Infrastructure</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Persistence\Mappers" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -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)
{

View File

@@ -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")]

View File

@@ -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()
{

View File

@@ -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);

View File

@@ -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<IDataEditor>()));
dtdRepository = new DataTypeRepository(scopeAccessor, appCaches, new Lazy<PropertyEditorCollection>(() => editors), Logger, TestHelper.IOHelper);
dtdRepository = new DataTypeRepository(scopeAccessor, appCaches, new Lazy<PropertyEditorCollection>(() => editors), Logger, IOHelper, new Lazy<IDataTypeService>(() => DataTypeService), LocalizedTextService, LocalizationService, ShortStringHelper);
return ctRepository;
}

View File

@@ -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;