mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
35669502cc
Performance is much better (might save ~20ms on startup), plus more popular in general means potentially easier for others to contribute/use the code.
22 lines
585 B
C#
22 lines
585 B
C#
using Autofac;
|
|
|
|
namespace NAPS2;
|
|
|
|
public class AutofacOperationFactory : IOperationFactory
|
|
{
|
|
private readonly IComponentContext _container;
|
|
private readonly ErrorOutput _errorOutput;
|
|
|
|
public AutofacOperationFactory(IComponentContext container, ErrorOutput errorOutput)
|
|
{
|
|
_container = container;
|
|
_errorOutput = errorOutput;
|
|
}
|
|
|
|
public T Create<T>() where T : IOperation
|
|
{
|
|
var op = _container.Resolve<T>();
|
|
op.Error += (sender, args) => _errorOutput.DisplayError(args.ErrorMessage, args.Exception);
|
|
return op;
|
|
}
|
|
} |