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