using System;
using System.Xml;
using nft.util;

namespace nft.framework.plugin
{
	/// <summary>
	/// Loads a Contribution from a designated class by passing the XmlElement
	/// to its constructor
	/// </summary>
    [Obsolete]
	public class FixedClassContributionFactory : IContributionFactory
	{
		/// <param name="concreteType">
		/// Type of the class to be used to load the class.
		/// </param>
		public FixedClassContributionFactory( Type concreteType ) {
			this.concreteType = concreteType;
		}
		/// <summary>
		/// Constructor for the use in plugin.xml
		/// </summary>
        public FixedClassContributionFactory(ParamsReader e) :
			this( PluginUtil.loadTypeFromManifest(e["implementation"])){}

		private readonly Type concreteType;
		public Type OutputType { get{ return concreteType; } }

        public Contribution load(Plugin owner, ParamsReader e) {
			return (Contribution)Activator.CreateInstance(concreteType,new object[]{owner, e});
		}

        public string Description {
            get { return null; }
        }
	}
}
