Removed (almost) all instances of Current.ShortStringHlper and replaced with constructor injection.

This commit is contained in:
Andy Butland
2019-12-20 17:36:44 +01:00
parent d624005355
commit d469a2153b
106 changed files with 573 additions and 589 deletions

View File

@@ -31,7 +31,7 @@ namespace Umbraco.Web.Models.Mapping
public ContentTypeMapDefinition(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IFileService fileService,
IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService,
ILogger logger)
ILogger logger, IShortStringHelper shortStringHelper)
{
_propertyEditors = propertyEditors;
_dataTypeService = dataTypeService;
@@ -40,7 +40,7 @@ namespace Umbraco.Web.Models.Mapping
_mediaTypeService = mediaTypeService;
_memberTypeService = memberTypeService;
_logger = logger;
_shortStringHelper = Current.ShortStringHelper;
_shortStringHelper = shortStringHelper;
}
@@ -510,7 +510,7 @@ namespace Umbraco.Web.Models.Mapping
{
MapTypeToDisplayBase(source, target);
var groupsMapper = new PropertyTypeGroupMapper<TTargetPropertyType>(_propertyEditors, _dataTypeService, _logger);
var groupsMapper = new PropertyTypeGroupMapper<TTargetPropertyType>(_propertyEditors, _dataTypeService, _shortStringHelper, _logger);
target.Groups = groupsMapper.Map(source);
}

View File

@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Composing;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Models.ContentEditing;
using Current = Umbraco.Core.Composing.Current;
@@ -17,12 +17,14 @@ namespace Umbraco.Web.Models.Mapping
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly IDataTypeService _dataTypeService;
private readonly IShortStringHelper _shortStringHelper;
private readonly ILogger _logger;
public PropertyTypeGroupMapper(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, ILogger logger)
public PropertyTypeGroupMapper(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IShortStringHelper shortStringHelper, ILogger logger)
{
_propertyEditors = propertyEditors;
_dataTypeService = dataTypeService;
_shortStringHelper = shortStringHelper;
_logger = logger;
}
@@ -152,7 +154,7 @@ namespace Umbraco.Web.Models.Mapping
// handle locked properties
var lockedPropertyAliases = new List<string>();
// add built-in member property aliases to list of aliases to be locked
foreach (var propertyAlias in ConventionsHelper.GetStandardPropertyTypeStubs(Current.ShortStringHelper).Keys)
foreach (var propertyAlias in ConventionsHelper.GetStandardPropertyTypeStubs(_shortStringHelper).Keys)
{
lockedPropertyAliases.Add(propertyAlias);
}

View File

@@ -13,6 +13,7 @@ using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Sections;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Actions;
using Umbraco.Web.Services;
@@ -27,9 +28,10 @@ namespace Umbraco.Web.Models.Mapping
private readonly ActionCollection _actions;
private readonly AppCaches _appCaches;
private readonly IGlobalSettings _globalSettings;
private readonly IShortStringHelper _shortStringHelper;
public UserMapDefinition(ILocalizedTextService textService, IUserService userService, IEntityService entityService, ISectionService sectionService,
AppCaches appCaches, ActionCollection actions, IGlobalSettings globalSettings)
AppCaches appCaches, ActionCollection actions, IGlobalSettings globalSettings, IShortStringHelper shortStringHelper)
{
_sectionService = sectionService;
_entityService = entityService;
@@ -38,11 +40,12 @@ namespace Umbraco.Web.Models.Mapping
_actions = actions;
_appCaches = appCaches;
_globalSettings = globalSettings;
_shortStringHelper = shortStringHelper;
}
public void DefineMaps(UmbracoMapper mapper)
{
mapper.Define<UserGroupSave, IUserGroup>((source, context) => new UserGroup(Current.ShortStringHelper) { CreateDate = DateTime.UtcNow }, Map);
mapper.Define<UserGroupSave, IUserGroup>((source, context) => new UserGroup(_shortStringHelper) { CreateDate = DateTime.UtcNow }, Map);
mapper.Define<UserInvite, IUser>(Map);
mapper.Define<IProfile, ContentEditing.UserProfile>((source, context) => new ContentEditing.UserProfile(), Map);
mapper.Define<IReadOnlyUserGroup, UserGroupBasic>((source, context) => new UserGroupBasic(), Map);