public static void RegisterActorTaskSourcesServices(this DiContainer diContainer) { diContainer.Bind <IHumanActorTaskSource <ISectorTaskSourceContext> >() .FromMethod(injectContext => { var humanTaskSource = new HumanActorTaskSource <ISectorTaskSourceContext>(); var botTaskSource = injectContext.Container.Resolve <IActorTaskSource <ISectorTaskSourceContext> >(); var switchTaskSource = new SwitchHumanActorTaskSource <ISectorTaskSourceContext>(humanTaskSource, botTaskSource); return(switchTaskSource); }).AsSingle(); diContainer.Bind <IActorTaskControlSwitcher>().FromMethod(injectContext => { var taskSource = injectContext.Container.Resolve <IHumanActorTaskSource <ISectorTaskSourceContext> >(); return((SwitchHumanActorTaskSource <ISectorTaskSourceContext>)taskSource); }).AsSingle(); diContainer.Bind <IActorTaskSource <ISectorTaskSourceContext> >().To <HumanBotActorTaskSource <ISectorTaskSourceContext> >().AsSingle(); diContainer.Bind <IActorTaskSourceCollector>().FromMethod(injectContext => { var botTaskSource = injectContext.Container.Resolve <IActorTaskSource <ISectorTaskSourceContext> >(); var humanTaskSource = injectContext.Container.Resolve <IHumanActorTaskSource <ISectorTaskSourceContext> >(); return(new TaskSourceCollector(botTaskSource, humanTaskSource)); }).AsSingle(); diContainer.Bind <LogicStateTreePatterns>().AsSingle(); diContainer.Bind <ILogicStateFactory>().To <ZenjectLogicStateFactory>().AsSingle(); RegisterBotLogics(diContainer); }
public static void RegisterBot(this IServiceCollection serviceCollection) { serviceCollection.RegisterLogicState(); serviceCollection.AddSingleton <ILogicStateFactory>(factory => new ContainerLogicStateFactory(factory)); serviceCollection.AddSingleton <LogicStateTreePatterns>(); serviceCollection.AddSingleton <IHumanActorTaskSource>(serviceProvider => { var humanTaskSource = new HumanActorTaskSource(); var treePatterns = serviceProvider.GetRequiredService <LogicStateTreePatterns>(); var botTaskSource = new HumanBotActorTaskSource <ISectorTaskSourceContext>(treePatterns); var switchTaskSource = new SwitchHumanActorTaskSource <ISectorTaskSourceContext>(humanTaskSource, botTaskSource); return(switchTaskSource); }); serviceCollection.AddSingleton <IActorTaskSource>(provider => provider.GetRequiredService <IHumanActorTaskSource>()); }