/// <summary>
        /// Returns an object of the specified type.
        /// </summary>
        /// <param name="factoryService">The factory service.</param>
        /// <param name="type">The type of the object to be returned.</param>
        /// <returns>An instance of an object of the specified type.</returns>
        public static object Get(this IFactoryService factoryService, Type type)
        {
            var factory = factoryService.GetFactory(type);

            if (factory == null)
            {
                throw new InvalidOperationException($"No factory has been registered for {type.FullName}.");
            }

            return(factory.Get());
        }
 public async Task <IActionResult> GetFactoryById(int id)
 {
     try
     {
         return(Ok(await _service.GetFactory(id)));
     }
     catch
     {
         return(StatusCode(404));
     }
 }
 /// <summary>
 /// Returns the registered factory for the specified type.
 /// </summary>
 /// <typeparam name="T">The type of the object to be returned.</typeparam>
 /// <returns>An instance of an object of the specified type.</returns>
 public static IFactory <T> GetFactory <T>(this IFactoryService factoryService) where T : class => (IFactory <T>)factoryService.GetFactory(typeof(T));