using System;
using System.Reflection;
namespace Umbraco.Core.Composing
{
///
/// Indicates that a composer should be disabled.
///
///
/// If a type is specified, disables the composer of that type, else disables the composer marked with the attribute.
/// This attribute is *not* inherited.
/// This attribute applies to classes only, it is not possible to enable/disable interfaces.
/// Assembly-level has greater priority than
/// attribute when it is marking the composer itself, but lower priority that when it is referencing another composer.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class DisableAttribute : Attribute
{
///
/// Initializes a new instance of the class.
///
public DisableAttribute()
{ }
public DisableAttribute(string fullTypeName, string assemblyName)
{
DisabledType = Assembly.Load(assemblyName)?.GetType(fullTypeName);
}
///
/// Initializes a new instance of the class.
///
public DisableAttribute(Type disabledType)
{
DisabledType = disabledType;
}
///
/// Gets the disabled type, or null if it is the composer marked with the attribute.
///
public Type DisabledType { get; }
}
}