예제 #1
0
        private void InstallBindingsToSubContainer(DiContainer subContainer)
        {
            subContainer
            .Bind <IAvatarService>()
            .To <AvatarService>()
            .AsCached()
            .NonLazy();

            subContainer
            .Bind <IAvatarSystem>()
            .To <AvatarSystem>()
            .AsCached();

            subContainer
            .Bind <IAvatarRepository>()
            .To <AvatarRepository>()
            .AsCached();

            subContainer
            .BindInterfacesAndSelfTo <PlayerAvatarController>()
            .AsCached();

            subContainer
            .Bind <IAvatarController>()
            .WithId("Player")
            .To <PlayerAvatarController>()
            .FromResolve();


            subContainer
            .BindFactory <AvatarID, Presentation.Avatar, AvatarFactory>()
            .FromComponentInNewPrefab(_avatarPrefab);
        }
예제 #2
0
 public static ConditionCopyNonLazyBinder BindPrefabFactory <TContract, TContract2, TFactory>(
     this DiContainer diContainer)
     where TFactory : PlaceholderFactory <UnityEngine.Object, TContract2, TContract>
 {
     return(diContainer.BindFactory <UnityEngine.Object, TContract2, TContract, TFactory>()
            .FromFactory <PrefabFactory <TContract2, TContract> >());
 }
 public static void BindEntityFactory <TView, TPlaceholderFactory, TFactory>(this DiContainer container)
     where TView : EntityView
     where TPlaceholderFactory : EntityPlaceholderFactory <TView>
     where TFactory : IEntityFactory <TView>
 {
     container.BindFactory <TView, TPlaceholderFactory>()
     .FromFactory <TFactory>();
 }
    public static void BindPoolContainer <T, TViewModel>(this DiContainer container, GameObject[] prefabList)
        where T : DynamicView <TViewModel>
    {
        ViewPoolContainer <T, TViewModel> viewPoolContainer = new ViewPoolContainer <T, TViewModel>(prefabList, container);

        container.BindFactory <int, TViewModel, T, ViewPoolFactory <T, TViewModel> >()
        .FromMethod((cont, index, viewModel) => viewPoolContainer.SpawnFromPool(index, viewModel));
    }
예제 #5
0
        public override void Install(DiContainer container)
        {
            Container.Bind <IEncounterLocker>().To <EncounterLocker>().AsTransient();
            Container.Bind <IEncounterUnlocker>().To <EncounterUnlocker>().AsTransient();

            SignalBusInstaller.Install(container);
            container.DeclareSignal <SceneChangedSignal>().OptionalSubscriber();

            container.Bind <SizeManager>().To <SizeManager>().AsSingle();

            container.Bind <ICurve>().To <AccelerationCurve>().AsTransient();
            container.Bind <IShiftTransformsAnimator>().To <ShiftTransformsAnimator>().AsTransient();

            container.BindFactory <Object, GameObject, GameObjectFactory>()
            .FromFactory <PrefabFactory <GameObject> >();
            container.BindFactory <Object, RectTransform, RectTransformFactory>()
            .FromFactory <PrefabFactory <RectTransform> >();
        }
예제 #6
0
    protected override void Bind(DiContainer container)
    {
        container.Bind <DynamicModelContainer <DebuggableValueModel> >().ToSelf().AsCached();

        container.BindFactory <IDebuggableValueViewModel, DebuggableValueView, DebuggableValueViewFactory>()
        .FromMonoPoolableMemoryPool(x => x.WithInitialSize(10)
                                    .FromComponentInNewPrefab(DebugViewPrefab)
                                    .UnderTransformGroup(
                                        $"{nameof(DebugViewPrefab)} parent"));
    }
예제 #7
0
        public static void Install(DiContainer container)
        {
            container.BindInterfacesAndSelfTo <CustomComponentHandler>().AsSingle();
            container.Bind <BaseGameUiHandler>().AsSingle();
            container
            .BindFactory <Type, SubView.InitData, SubView, SubView.Factory>()
            .FromFactory <SubViewFactory>();
            container
            .BindFactory <Type, CustomViewController.InitData, CustomViewController, CustomViewController.Factory>()
            .FromFactory <ViewControllerFactory>();
            container
            .BindFactory <CustomScreen.InitData, CustomScreen, CustomScreen.Factory>()
            .FromFactory <ScreenFactory>();

            container.Bind <StyleSheetHandler>().AsSingle();
            container.BindInterfacesAndSelfTo <BsmlDecorator>().AsSingle();
            BindUiFactory <Popup, Popup.Factory>(container);
            BindUiFactory <CustomUiComponent, CustomUiComponent.Factory>(container);
        }
예제 #8
0
        public void TestFailure()
        {
            var container = new DiContainer(true);

            container.Settings = new ZenjectSettings(
                ValidationErrorResponses.Throw, RootResolveMethods.All);

            container.BindFactory <Foo, Foo.Factory>().FromPoolableMemoryPool <Foo>(x => x.WithInitialSize(2));

            Assert.Throws(() => container.ResolveRoots());
        }
예제 #9
0
    public static void BindPoolContainer <TPoolable, PoolFactory>(this DiContainer container, GameObject[] prefabList, int[] initialPoolSizes)
        where TPoolable : PoolableMonoBehaviour
        where PoolFactory : PlaceholderFactory <int, TPoolable>
    {
        PoolablePoolContainer <TPoolable> poolContainer = new PoolablePoolContainer <TPoolable>(prefabList, container, initialPoolSizes);

        container.BindFactory <int, TPoolable, PoolFactory>()
        .FromMethod((cont, index) => poolContainer.SpawnFromPool(index));

        container.Bind <IInitializable>().To <PoolablePoolContainer <TPoolable> >().FromInstance(poolContainer);
    }
        public void TestSuccess()
        {
            var container = new DiContainer(true);

            container.Settings = new ZenjectSettings(
                ValidationErrorResponses.Throw, RootResolveMethods.All);

            container.Bind <Bar>().AsSingle();
            container.BindFactory <Foo, Foo.Factory>().FromPoolableMemoryPool(x => x.WithInitialSize(2));

            container.ResolveRoots();
        }
예제 #11
0
 void InstallUIContainer(DiContainer subContainer)
 {
     subContainer.Bind <UIContainerFacade>().AsSingle();
     subContainer.BindInterfacesAndSelfTo <UIContainer>().FromComponentInNewPrefab(_containerPrefab).AsSingle();
     subContainer.BindInterfacesAndSelfTo <UIContainerManager>().FromComponentInNewPrefab(_manager).AsSingle();
     subContainer.BindFactory <UIContent, PlaceholderFactory <UIContent> >().FromMonoPoolableMemoryPool(x => x.FromComponentInNewPrefab(_contentPrefab).UnderTransform(GetContainerParent));
     subContainer.BindSignal <UIAddContentSignal>().ToMethod <UIContainerManager>(x => x.AddContentSignal).FromResolve();
     subContainer.BindSignal <UIRemoveContentSignal>().ToMethod <UIContainerManager>(x => x.RemoveContentSignal).FromResolve();
     subContainer.BindSignal <UIAddAllContentSignal>().ToMethod <UIContainerManager>(x => x.AddAllContentSignal).FromResolve();
     subContainer.BindSignal <UIRemoveAllContentSignal>().ToMethod <UIContainerManager>(x => x.RemoveAllContentSignal).FromResolve();
     subContainer.BindSignal <UIClearContainerSignal>().ToMethod <UIContainerManager>(x => x.ClearContainerSignal).FromResolve();
     subContainer.BindSignal <UIUpdateContainerSignal>().ToMethod <UIContainerManager>(x => x.UpdateContainerSignal).FromResolve();
     subContainer.BindSignal <UIGlobalContainerSignal>().ToMethod <UIContainerManager>(x => x.GlobalContainerSignal).FromResolve();
 }
예제 #12
0
    public static void BindMonoPrefabPool <T, TArgs, TFactory, TPool>(this DiContainer Container, Identifiers id, int size, T prefab, Transform parentTransform, BindingCondition cond = null)
        where T : MonoBehaviour, IPoolable <TArgs, IMemoryPool>
        where TFactory : PlaceholderFactory <TArgs, T>
        where TPool : MonoPoolableMemoryPool <TArgs, IMemoryPool, T>
    {
        var bind =
            Container.BindFactory <TArgs, T, TFactory>().
            WithId(id).
            FromPoolableMemoryPool <TArgs, T, TPool>
                (x => x.WithInitialSize(size).
                ExpandByDoubling().
                FromComponentInNewPrefab(prefab).
                UnderTransform(parentTransform));

        if (cond != null)
        {
            bind.When(cond);
        }
    }
예제 #13
0
    public static void BindMonoPrefabPool <T, TArgs, TFactory, TPool>(this DiContainer Container, Identifiers id, int size, GameObject prefab, string transformGroupName, BindingCondition cond = null)
        where T : IComponent, IPoolable <TArgs, IMemoryPool>
        where TFactory : PlaceholderFactory <TArgs, T>
        where TPool : ContextGameObjectMemoryPool <TArgs, IMemoryPool, T>
    {
        var bind =
            Container.BindFactory <TArgs, T, TFactory>().
            WithId(id).
            FromPoolableMemoryPool <TArgs, T, TPool>
                (x => x.WithInitialSize(size).
                ExpandByDoubling().
                FromComponentInNewPrefab(prefab).
                UnderTransformGroup(transformGroupName));

        if (cond != null)
        {
            bind.When(cond);
        }
    }
예제 #14
0
    public static void BindMonoContextPool <T, TArgs, TFactory, TPool>(this DiContainer Container, Identifiers id, int size, T prefab, string transformGroupName, BindingCondition cond = null)
        where T : MonoBehaviour, IPoolable <TArgs, IMemoryPool>
        where TFactory : PlaceholderFactory <TArgs, T>
        where TPool : MonoPoolableMemoryPool <TArgs, IMemoryPool, T>
    {
        var bind =
            Container.BindFactory <TArgs, T, TFactory>().
            WithId(id).
            FromPoolableMemoryPool <TArgs, T, TPool>
                (x => x.WithInitialSize(size).
                ExpandByDoubling().
                FromSubContainerResolve().
                ByNewContextPrefab(prefab).
                UnderTransformGroup(transformGroupName));

        if (cond != null)
        {
            bind.When(cond);
        }
    }
예제 #15
0
 private void InstallEnemyBlack(DiContainer subContainer)
 {
     subContainer.BindFactory <EnemyBlackController, EnemyBlackController.Factory>();
 }
 private void BindTexturePainter(DiContainer container)
 {
     container.Bind <TexturePainter.TexturePainter>().AsSingle();
     container.BindFactory <Sprite, ISpriteState, SpriteState.Factory>().To <SpriteState>()
     .AsSingle();
 }