using System;

namespace skyscraper5.Skyscraper.Plugins
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
	public sealed class DescriptorPluginBatHandlerAttribute : Attribute
	{
		public DescriptorPluginBatHandlerAttribute(Type handler)
		{
			object boxed = Activator.CreateInstance(handler);
			DescriptorPluginBatHandler unboxed = (DescriptorPluginBatHandler)boxed;
			if (unboxed == null)
			{
				throw new NotImplementedException(String.Format("{0} is not an {1}", handler.Name, nameof(DescriptorPluginBatHandler)));
			}

			Handler = unboxed;
		}

		public DescriptorPluginBatHandler Handler { get; private set; }
	}
}
