using System; namespace Umbraco.Core.Components { /// /// Indicates that a component is required by another component. /// /// /// fixme /// This attribute is *not* inherited. This means that a component class inheriting from /// another component class does *not* inherit its requirements. However, the bootloader checks /// the *interfaces* of every component for their requirements, so requirements declared on /// interfaces are inherited by every component class implementing the interface. /// When targetting a class, indicates a dependency on the component which must be enabled, /// unless the requirement has explicitely been declared as weak (and then, only if the component /// is enabled). /// When targetting an interface, indicates a dependency on enabled components implementing /// the interface. It could be no component at all, unless the requirement has explicitely been /// declared as strong (and at least one component must be enabled). /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] public class RequiredComponentAttribute : Attribute { /// /// Initializes a new instance of the class. /// /// The type of the required component. public RequiredComponentAttribute(Type requiringType) { if (typeof(IUmbracoComponent).IsAssignableFrom(requiringType) == false) throw new ArgumentException($"Type {requiringType.FullName} is invalid here because it does not implement {typeof(IUmbracoComponent).FullName}."); RequiringType = requiringType; } /// /// Gets the required type. /// public Type RequiringType { get; } } }