當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。