2020-02-19 16:37:00 +11:00
|
|
|
using System.Collections.Generic;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Composing;
|
|
|
|
|
using Umbraco.Cms.Core.Models;
|
2020-02-19 16:37:00 +11:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Core.PropertyEditors
|
2020-02-19 16:37:00 +11:00
|
|
|
{
|
|
|
|
|
public class MediaUrlGeneratorCollection : BuilderCollectionBase<IMediaUrlGenerator>
|
|
|
|
|
{
|
|
|
|
|
public MediaUrlGeneratorCollection(IEnumerable<IMediaUrlGenerator> items) : base(items)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-06 15:09:56 -06:00
|
|
|
public bool TryGetMediaPath(string propertyEditorAlias, object value, out string mediaPath)
|
2020-02-19 16:37:00 +11:00
|
|
|
{
|
2021-07-06 15:09:56 -06:00
|
|
|
foreach(IMediaUrlGenerator generator in this)
|
2020-02-19 16:37:00 +11:00
|
|
|
{
|
2021-07-06 15:09:56 -06:00
|
|
|
if (generator.TryGetMediaPath(propertyEditorAlias, value, out var mp))
|
2020-02-19 16:37:00 +11:00
|
|
|
{
|
|
|
|
|
mediaPath = mp;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mediaPath = null;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|