public static RegistrationBuilder RegisterComponent <TInterface>(this IContainerBuilder builder, TInterface component)
        {
            var registrationBuilder = new ComponentRegistrationBuilder(component).As(typeof(TInterface));

            // Force inject execution
            builder.RegisterBuildCallback(container => container.Resolve <TInterface>());
            return(builder.Register(registrationBuilder));
        }
        public static RegistrationBuilder RegisterComponent <TInterface>(this IContainerBuilder builder, TInterface component)
        {
            var registrationBuilder = new ComponentRegistrationBuilder(component).As(typeof(TInterface));

            // Force inject execution
            registrationBuilder.OnAfterBuild((registration, container) => registration.SpawnInstance(container));
            return(builder.Register(registrationBuilder));
        }
Ejemplo n.º 3
0
        public static ComponentRegistrationBuilder RegisterComponentInHierarchy <T>(this IContainerBuilder builder)
        {
            var lifetimeScope = (LifetimeScope)builder.ApplicationOrigin;
            var scene         = lifetimeScope.gameObject.scene;

            var registrationBuilder = new ComponentRegistrationBuilder(scene, typeof(T));

            builder.Register(registrationBuilder);
            return(registrationBuilder);
        }
        public static ComponentRegistrationBuilder RegisterComponentInHierarchy <T>(this IContainerBuilder builder)
        {
            var lifetimeScope = (LifetimeScope)builder.ApplicationOrigin;
            var scene         = lifetimeScope.gameObject.scene;

            var registrationBuilder = new ComponentRegistrationBuilder(scene, typeof(T));

            // Force inject execution
            builder.RegisterBuildCallback(container => container.Resolve <T>());
            return(builder.Register(registrationBuilder));
        }
        public static ComponentRegistrationBuilder RegisterComponentInHierarchy <T>(this IContainerBuilder builder)
        {
            var lifetimeScope = (LifetimeScope)builder.ApplicationOrigin;
            var scene         = lifetimeScope.gameObject.scene;

            var registrationBuilder = new ComponentRegistrationBuilder(scene, typeof(T));

            // Force inject execution
            registrationBuilder.OnAfterBuild((registration, container) => registration.SpawnInstance(container));
            return(builder.Register(registrationBuilder));
        }
Ejemplo n.º 6
0
        public static ComponentRegistrationBuilder RegisterComponentInNewPrefab <T>(
            this IContainerBuilder builder,
            T prefab,
            Lifetime lifetime)
            where T : Component
        {
            var registrationBuilder = new ComponentRegistrationBuilder(
                prefab,
                typeof(T),
                lifetime);

            builder.Register(registrationBuilder);
            return(registrationBuilder);
        }
Ejemplo n.º 7
0
        public static ComponentRegistrationBuilder RegisterComponentOnNewGameObject <T>(
            this IContainerBuilder builder,
            Lifetime lifetime,
            string newGameObjectName = null)
            where T : Component
        {
            var registrationBuilder = new ComponentRegistrationBuilder(
                newGameObjectName,
                typeof(T),
                lifetime);

            builder.Register(registrationBuilder);
            return(registrationBuilder);
        }