Files
Umbraco-CMS/src/Umbraco.Web.Common/Attributes/PluginControllerAttribute.cs

31 lines
1.0 KiB
C#
Raw Normal View History

2020-04-20 12:20:47 +02:00
using System;
using System.Linq;
namespace Umbraco.Web.Common.Attributes
{
/// <summary>
2020-05-07 10:00:18 +02:00
/// Indicates that a controller is a plugin controller and should be routed to its own area.
2020-04-20 12:20:47 +02:00
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class PluginControllerAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="PluginControllerAttribute"/> class.
/// </summary>
/// <param name="areaName"></param>
public PluginControllerAttribute(string areaName)
{
// validate this, only letters and digits allowed.
if (areaName.Any(c => !char.IsLetterOrDigit(c)))
throw new FormatException($"Invalid area name \"{areaName}\": the area name can only contains letters and digits.");
AreaName = areaName;
}
/// <summary>
/// Gets the name of the area.
/// </summary>
public string AreaName { get; }
}
}