using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors.ValueConverters;
namespace Umbraco.Cms.Core.Models;
/// <summary>
/// Represents a media item with local crops.
/// </summary>
/// <seealso cref="PublishedContentWrapped" />
public class MediaWithCrops : PublishedContentWrapped
{
/// Initializes a new instance of the <see cref="MediaWithCrops" /> class.
/// <param name="content">The content.</param>
/// <param name="publishedValueFallback">The published value fallback.</param>
/// <param name="localCrops">The local crops.</param>
public MediaWithCrops(IPublishedContent content, IPublishedValueFallback publishedValueFallback, ImageCropperValue localCrops)
: base(content, publishedValueFallback) =>
LocalCrops = localCrops;
/// Gets the content/media item.
/// <value>
/// The content/media item.
/// </value>
public IPublishedContent Content => Unwrap();
/// Gets the local crops.
/// The local crops.
public ImageCropperValue LocalCrops { get; }
}
/// <typeparam name="T">The type of the media item.</typeparam>
public class MediaWithCrops<T> : MediaWithCrops
where T : IPublishedContent
/// Initializes a new instance of the <see cref="MediaWithCrops{T}" /> class.
public MediaWithCrops(T content, IPublishedValueFallback publishedValueFallback, ImageCropperValue localCrops)
: base(content, publishedValueFallback, localCrops) =>
Content = content;
/// Gets the media item.
/// The media item.
public new T Content { get; }
/// Performs an implicit conversion from <see cref="MediaWithCrops{T}" /> to <typeparamref name="T"/>.
/// <param name="mediaWithCrops">The media with crops.</param>
/// <returns>
/// The result of the conversion.
/// </returns>
public static implicit operator T(MediaWithCrops<T> mediaWithCrops) => mediaWithCrops.Content;