refactor: Remove IServiceCommand from composition root

Registering this type fails the unit tests because it cannot be
constructed unless you use Lazy<> otherwise it throws due to the active
service command not being set yet in the IActiveServiceCommandProvider
class.
pull/47/head
Robert Dailey 2 years ago
parent 8d1706ca02
commit 7451b8526c

@ -1,17 +1,16 @@
using System;
using TrashLib.Cache;
using TrashLib.Cache;
namespace Trash.Command.Helpers
{
public class CacheStoragePath : ICacheStoragePath
{
private readonly Lazy<IServiceCommand> _cmd;
private readonly IActiveServiceCommandProvider _serviceCommandProvider;
public CacheStoragePath(Lazy<IServiceCommand> cmd)
public CacheStoragePath(IActiveServiceCommandProvider serviceCommandProvider)
{
_cmd = cmd;
_serviceCommandProvider = serviceCommandProvider;
}
public string Path => _cmd.Value.CacheStoragePath;
public string Path => _serviceCommandProvider.ActiveCommand.CacheStoragePath;
}
}

@ -69,9 +69,6 @@ namespace Trash
builder.RegisterType<ActiveServiceCommandProvider>()
.As<IActiveServiceCommandProvider>()
.SingleInstance();
builder.Register(c => c.Resolve<IActiveServiceCommandProvider>().ActiveCommand)
.As<IServiceCommand>();
}
public static IContainer Setup()

Loading…
Cancel
Save