2017-09-27 21:16:09 +02:00
using System ;
2021-02-18 11:06:02 +01:00
namespace Umbraco.Cms.Core.Models.PublishedContent
2017-09-27 21:16:09 +02:00
{
/// <inheritdoc />
/// <summary>
/// Indicates that the class is a published content model for a specified content type.
/// </summary>
/// <remarks>By default, the name of the class is assumed to be the content type alias. The
/// <c>PublishedContentModelAttribute</c> can be used to indicate a different alias.</remarks>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
2017-10-26 11:25:01 +02:00
public sealed class PublishedModelAttribute : Attribute
2017-09-27 21:16:09 +02:00
{
/// <inheritdoc />
/// <summary>
2017-10-26 11:25:01 +02:00
/// Initializes a new instance of the <see cref="PublishedModelAttribute" /> class with a content type alias.
2017-09-27 21:16:09 +02:00
/// </summary>
/// <param name="contentTypeAlias">The content type alias.</param>
2017-10-26 11:25:01 +02:00
public PublishedModelAttribute ( string contentTypeAlias )
2017-09-27 21:16:09 +02:00
{
2019-10-07 22:10:21 +02:00
if ( contentTypeAlias = = null ) throw new ArgumentNullException ( nameof ( contentTypeAlias ) ) ;
if ( string . IsNullOrWhiteSpace ( contentTypeAlias ) ) throw new ArgumentException ( "Value can't be empty or consist only of white-space characters." , nameof ( contentTypeAlias ) ) ;
2017-09-27 21:16:09 +02:00
ContentTypeAlias = contentTypeAlias ;
}
/// <summary>
/// Gets or sets the content type alias.
/// </summary>
public string ContentTypeAlias { get ; }
}
}