CompatibilityRunning Selvage beside Zenject or VContainer. Each module compiles only when its container is in the project.
Zenject
Provider that supplies what a Zenject container has bound. It asks the container nearest the context: the GameObjectContext in its parents, else its scene's SceneContext, else the ProjectContext. A member's channel is tried first as the binding identifier, then without one, and a collection member receives every binding of its element type. What it supplies is borrowed: the container owns it. Bindings exist only once installers run in Play mode, so the Validation tab shows a member only this provider may supply as May Be Supplied. The provider list holds at most one, reached with ZenjectProvider.Listed.
Static properties
| ZenjectProvider Listed { get; } | The ZenjectProvider in the provider list, enabled or not. It stays the same object until scripts are reloaded. In a build, the provider list loads before the first scene, so read it from RuntimeInitializeLoadType.BeforeSceneLoad on. Throws InvalidOperationException when the provider list has no ZenjectProvider or, in a build, when read before the list has loaded. |
Properties
| Zenject.Context ZenjectContext { get; set; } | The Zenject context whose container is asked for every member, or null (the default) for the container nearest each context. Set it from code: Project Settings cannot reference a scene object. |
Zenject bindings whose instances come from Selvage.
Static methods
| ScopeConcreteIdArgConditionCopyNonLazyBinder FromSelvage(this FromBinder binder) | Takes the bound type's instances from Selvage, for a constructor parameter, an [Inject] method, or code that cannot use a Selvage member: Container.Bind<IAudio>().FromSelvage().AsCached();. Selvage is asked on every resolution of a transient binding, and once for a cached one. The binding's identifier is the channel, and a type named with To<T>() is the type Selvage is asked for. What Selvage supplies is held until the container holding the binding is disposed. Only an answer ready at once counts. Throws ZenjectException when Selvage supplies nothing for an injection that is not optional. |
VContainer
Provider that supplies what a VContainer scope has registered. It asks the scope nearest the context: the LifetimeScope in its parents, else the first one in its scene, else the root scope. A member's channel is tried first as the registration key, then without one, and a collection member receives every registration of its element type. What it supplies is borrowed: the container owns it. Registrations exist only once scopes are built in Play mode, so the Validation tab shows a member only this provider may supply as May Be Supplied. The provider list holds at most one, reached with VContainerProvider.Listed.
Static properties
| VContainerProvider Listed { get; } | The VContainerProvider in the provider list, enabled or not. It stays the same object until scripts are reloaded. In a build, the provider list loads before the first scene, so read it from RuntimeInitializeLoadType.BeforeSceneLoad on. Throws InvalidOperationException when the provider list has no VContainerProvider or, in a build, when read before the list has loaded. |
Properties
| LifetimeScope Scope { get; set; } | The scope whose container is asked for every member, or null (the default) for the scope nearest each context. Set it from code: Project Settings cannot reference a scene object. |
VContainer registrations whose instances come from Selvage.
Static methods
| RegistrationBuilder RegisterFromSelvage<T>(this IContainerBuilder builder, object channel = null, Lifetime lifetime = Lifetime.Singleton) | Registers T with its instances taken from Selvage, for a constructor parameter, an [Inject] method, or code that cannot use a Selvage member: builder.RegisterFromSelvage<IAudio>();. channel is the channel Selvage receives, for example the key given with .Keyed(...). lifetime is VContainer's: Selvage is asked once with Singleton, and on every resolution with Transient. What Selvage supplies is held until the scope is disposed, and Selvage, not VContainer, ends it. Only an answer ready at once counts. Throws ArgumentException for Lifetime.Scoped, and VContainerException on resolution when Selvage supplies nothing. |