本文整理汇总了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();
}
}
}
}
示例2: Setup
public virtual void Setup()
{
_container = new DiContainer();
InstallBindings();
Validate();
_container.Inject(this);
}
示例3: AddPostBindings
public void AddPostBindings(DiContainer container)
{
foreach (var installer in PostInstallers)
{
container.Inject(installer);
installer.InstallBindings();
}
ProcessDecoratorInstallers(container, false);
}
示例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();
}
}
示例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());
}
示例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();
}
示例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();
}
}
}
}