using System;

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

			Handler = unboxed;
		}

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