using System; using Syntriax.Engine.Core.Factory.Abstract; namespace Syntriax.Engine.Core.Factory; public abstract class FactoryBase : IFactory where TInterface : class { public virtual T Get(params object?[]? args) where T : class, TInterface { T? result; if (args is not null && args.Length != 0) result = Activator.CreateInstance(typeof(T), args) as T; else result = Activator.CreateInstance(typeof(T)) as T; if (result is null) throw new Exception($"{typeof(TInterface).Name} of type {typeof(T).Name} could not be created."); return result; } }