当前位置: 首页>>代码示例>>C#>>正文


C# DiContainer.Inject方法代码示例

本文整理汇总了C#中Zenject.DiContainer.Inject方法的典型用法代码示例。如果您正苦于以下问题:C# DiContainer.Inject方法的具体用法?C# DiContainer.Inject怎么用?C# DiContainer.Inject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zenject.DiContainer的用法示例。


在下文中一共展示了DiContainer.Inject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessDecoratorInstallers

        void ProcessDecoratorInstallers(DiContainer container, bool isBefore)
        {
            if (DecoratorInstallers == null)
            {
                return;
            }

            foreach (var installer in DecoratorInstallers)
            {
                if (installer == null)
                {
                    Log.Warn("Found null installer in composition root");
                    continue;
                }

                if (installer.enabled)
                {
                    container.Inject(installer);

                    if (isBefore)
                    {
                        installer.PreInstallBindings();
                    }
                    else
                    {
                        installer.PostInstallBindings();
                    }
                }
            }
        }
开发者ID:IllusiveS,项目名称:Asteroids,代码行数:30,代码来源:SceneDecoratorCompositionRoot.cs

示例2: Setup

        public virtual void Setup()
        {
            _container = new DiContainer();
            InstallBindings();

            Validate();
            _container.Inject(this);
        }
开发者ID:4xisblack,项目名称:Zenject,代码行数:8,代码来源:TestWithContainer.cs

示例3: AddPostBindings

        public void AddPostBindings(DiContainer container)
        {
            foreach (var installer in PostInstallers)
            {
                container.Inject(installer);
                installer.InstallBindings();
            }

            ProcessDecoratorInstallers(container, false);
        }
开发者ID:Soren025,项目名称:Zenject,代码行数:10,代码来源:SceneDecoratorContext.cs

示例4: Setup

        public virtual void Setup()
        {
            _container = new DiContainer(false);
            InstallBindings();

            _container.Validate();
            _container.Inject(this);

            foreach (var initializable in Container.ResolveAll<IInitializable>(true))
            {
                initializable.Initialize();
            }
        }
开发者ID:Soren025,项目名称:Zenject,代码行数:13,代码来源:ZenjectUnitTestFixture.cs

示例5: RebindingInSubContainer2

        public void RebindingInSubContainer2()
        {
            DiContainer parentContainer = new DiContainer();
            parentContainer.Bind<IHaveMessage>().ToSingle<Welcome>();

            Assert.AreEqual("Welcome", parentContainer.Resolve<IHaveMessage>().GetMessage());

            DiContainer childContainer = parentContainer.CreateSubContainer();
            User user = new User();
            childContainer.Inject(user);

            Assert.AreEqual("Welcome", user.SayIt());
            user.Rebind();
            Assert.AreEqual("Bye", user.SayIt());

            parentContainer.Inject(user);
            Assert.AreEqual("Welcome", user.SayIt());
        }
开发者ID:Aszan,项目名称:Zenject,代码行数:18,代码来源:TestSubContainer2.cs

示例6: OnEnable

        public virtual void OnEnable()
        {
            _container = new DiContainer(StaticContext.Container);

            // Make sure we don't create any game objects since editor windows don't have a scene
            _container.AssertOnNewGameObjects = true;

            _container.Bind<TickableManager>().AsSingle();
            _container.Bind<InitializableManager>().AsSingle();
            _container.Bind<DisposableManager>().AsSingle();
            _container.Bind<GuiRenderableManager>().AsSingle();

            InstallBindings();

            _container.Inject(this);

            _initializableManager.Initialize();
        }
开发者ID:Soren025,项目名称:Zenject,代码行数:18,代码来源:ZenjectEditorWindow.cs

示例7: ProcessDecoratorInstallers

        void ProcessDecoratorInstallers(DiContainer container, bool isBefore)
        {
            if (DecoratorInstallers == null)
            {
                return;
            }

            foreach (var installer in DecoratorInstallers)
            {
                Assert.IsNotNull(installer, "Found null installer in SceneDecoratorContext");

                if (installer.enabled)
                {
                    container.Inject(installer);

                    if (isBefore)
                    {
                        installer.PreInstallBindings();
                    }
                    else
                    {
                        installer.PostInstallBindings();
                    }
                }
            }
        }
开发者ID:Soren025,项目名称:Zenject,代码行数:26,代码来源:SceneDecoratorContext.cs


注:本文中的Zenject.DiContainer.Inject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。