You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Trash/Config/ObjectFactory.cs

24 lines
604 B

using System;
using Autofac;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.ObjectFactories;
namespace Trash.Config
{
public class ObjectFactory : IObjectFactory
{
private readonly ILifetimeScope _container;
private readonly DefaultObjectFactory _defaultFactory = new();
public ObjectFactory(ILifetimeScope container)
{
_container = container;
}
public object Create(Type type)
{
return _container.IsRegistered(type) ? _container.Resolve(type) : _defaultFactory.Create(type);
}
}
}