Manually merges the IgnorePublishedContentCollisions change, removes more service locator pattern, removes ContextMapper with UmbracoContext and instead uses IUmbracoContextAccessor and adjusts some DI.

This commit is contained in:
Shannon
2018-07-18 14:34:32 +10:00
parent 66f9eb01c7
commit ec1d013004
21 changed files with 293 additions and 259 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using Umbraco.Core.Models;
@@ -11,9 +12,17 @@ namespace Umbraco.Web.Models.Mapping
/// </summary>
internal class MemberBasicPropertiesResolver : IValueResolver<IMember, MemberBasic, IEnumerable<ContentPropertyBasic>>
{
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
public MemberBasicPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor)
{
_umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor));
}
public IEnumerable<ContentPropertyBasic> Resolve(IMember source, MemberBasic destination, IEnumerable<ContentPropertyBasic> destMember, ResolutionContext context)
{
var umbracoContext = context.GetUmbracoContext();
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
if (umbracoContext == null) throw new InvalidOperationException("Cannot resolve value without an UmbracoContext available");
var result = Mapper.Map<IEnumerable<Property>, IEnumerable<ContentPropertyBasic>>(
// Sort properties so items from different compositions appear in correct order (see U4-9298). Map sorted properties.
@@ -39,4 +48,4 @@ namespace Umbraco.Web.Models.Mapping
return result;
}
}
}
}