using System.Reflection;
using Quadarax.Foundation.Core.Data;
using Quadarax.Foundation.Core.Object;
using Quadarax.Foundation.Core.Reflection;

namespace Quadarax.Foundation.Core.Business.Processor.Task.ExecuteProvider
{
    internal class TaskExecuteProviderFactory
    {

        public TaskExecuteProviderFactory()
        {

        }

        public ITaskExecuteProvider Create(string providerClass, ITypedArgument[] arguments)
        {
            var type = TypeUtils.GetRemoteType(providerClass);
            if (type == null) throw new Exception($"Cannot find type {providerClass}");

            return (ITaskExecuteProvider)Activator.CreateInstance(type, arguments);
        }
    }
}
