Files
Umbraco-CMS/src/Umbraco.Web/Models/Mapping/MediaAppResolver.cs

27 lines
947 B
C#
Raw Normal View History

using System.Collections.Generic;
using AutoMapper;
using Umbraco.Core.Models;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Mapping
{
// injected into ContentMapperProfile,
// maps ContentApps when mapping IMedia to MediaItemDisplay
internal class MediaAppResolver : IValueResolver<IMedia, MediaItemDisplay, IEnumerable<ContentApp>>
{
2018-12-07 14:05:47 +01:00
private readonly ContentAppFactoryCollection _contentAppDefinitions;
2018-12-07 14:05:47 +01:00
public MediaAppResolver(ContentAppFactoryCollection contentAppDefinitions)
{
_contentAppDefinitions = contentAppDefinitions;
}
public IEnumerable<ContentApp> Resolve(IMedia source, MediaItemDisplay destination, IEnumerable<ContentApp> destMember, ResolutionContext context)
{
return _contentAppDefinitions.GetContentAppsFor(source);
}
}
}