mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-19 03:37:38 +03:00
22 lines
546 B
C#
22 lines
546 B
C#
using Ninject;
|
|
|
|
namespace NAPS2;
|
|
|
|
public class NinjectOperationFactory : IOperationFactory
|
|
{
|
|
private readonly IKernel _kernel;
|
|
private readonly ErrorOutput _errorOutput;
|
|
|
|
public NinjectOperationFactory(IKernel kernel, ErrorOutput errorOutput)
|
|
{
|
|
_kernel = kernel;
|
|
_errorOutput = errorOutput;
|
|
}
|
|
|
|
public T Create<T>() where T : IOperation
|
|
{
|
|
var op = _kernel.Get<T>();
|
|
op.Error += (sender, args) => _errorOutput.DisplayError(args.ErrorMessage, args.Exception);
|
|
return op;
|
|
}
|
|
} |