Итак, у нас есть два класса, реализующих интерфейс IStateRepository
: FileRepo
and DBRepo
(реализация вне контекста). И класс-потребитель:
public class StateBase : IStateAdapter
{
public StateBase(
ILogger logger,
SourceConfiguration source,
StateConfiguration state,
IIndex<StorageType, IStateRepository> repoService)
{
_stateStorage = repoService[state.StorageType];
}
}
Регистрация классов и их зависимостей:
var _builder = new ContainerBuilder();
_builder.RegisterInstance(_logger).As<ILogger>();
_builder.RegisterInstance(config.Source).As<SourceConfiguration>();
_builder.RegisterInstance(config.State).As<StateConfiguration>();
_builder.RegisterType<CsvFileRepository>().Keyed<IStateRepository>(StorageType.File)
.UsingConstructor(typeof(ILogger), typeof(StateConfiguration));
_builder.RegisterType<MsSqlDataRepository>().Keyed<IStateRepository>(StorageType.Database)
// Register State Adapter
_builder.RegisterType<StateAsID>().Keyed<IStateAdapter>(StateType.ID);
_builder.RegisterType<StateAsRowVersion>().Keyed<IStateAdapter>(StateType.RowVersion);
_builder.RegisterType<StateAsTimeStamp>().Keyed<IStateAdapter>(StateType.TimeStamp);
_builder.RegisterType<StateAsFixedRange>().Keyed<IStateAdapter>(StateType.FixedRange);
Однако когда я пытаюсь отрезолвить реализацию IStateAdapter
:
var state = _container.ResolveKeyed<IStateAdapter>(config.Source.LastStateType);
Падает следующий exception
None of the constructors found with
'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type
'BI.Generic.PipeLine.StateAdapters.StateAsRowVersion' can be invoked
with the available services and parameters:\r\nCannot resolve
parameter
'Scalepoint.BI.Generic.Core.Interfaces.IIndex2[BI.Generic.Core.StorageType,BI.Generic.PipeLine.StateAdapters.IStateRepository]
repoService' of constructor 'Void .ctor(Serilog.ILogger,
BI.Generic.Core.SourceConfiguration,
BI.Generic.Core.StateConfiguration,
BI.Generic.Core.Interfaces.IIndex
2[BI.Generic.Core.StorageType,BI.Generic.PipeLine.StateAdapters.IStateRepository])'.
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Виртуальный выделенный сервер (VDS) становится отличным выбором
Есть 2 textBox'а, один 1 другой второйВ них вписываю информацию в первый "Jule" во второй "June"
Правильно ли я понимаю, только когда в while придет false, тогда закончится метод StartWork?