ConvertibleAttribute
Declares a type as being convertible by a ITypeConverter and optionally defines the converter to be used
using Castle.Core.Internal;
using System;
namespace Castle.MicroKernel.SubSystems.Conversion
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public class ConvertibleAttribute : Attribute
{
private readonly Type converterType;
public Type ConverterType => converterType;
public ConvertibleAttribute()
: this(typeof(DefaultComplexConverter))
{
}
public ConvertibleAttribute(Type converterType)
{
if (!converterType.Is<ITypeConverter>())
throw new ArgumentException($"""{converterType.FullName}""{typeof(ITypeConverter).FullName}""", "converterType");
this.converterType = converterType;
}
}
}