Exemple #1
0
        public GameObjectNameGroupNameScopeArgBinder FromGameObject()
        {
            BindingUtil.AssertIsAbstractOrComponentOrGameObject(BindInfo.ContractTypes);
            BindingUtil.AssertIsComponentOrGameObject(ConcreteTypes);

            var gameObjectInfo = new GameObjectCreationParameters();

            if (ConcreteTypes.All(x => x == typeof(GameObject)))
            {
                SubFinalizer = new ScopableBindingFinalizer(
                    BindInfo, SingletonTypes.ToGameObject, gameObjectInfo,
                    (container, type) =>
                {
                    Assert.That(BindInfo.Arguments.IsEmpty(), "Cannot inject arguments into empty game object");
                    return(new EmptyGameObjectProvider(
                               container, gameObjectInfo));
                });
            }
            else
            {
                BindingUtil.AssertIsComponent(ConcreteTypes);
                BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes);

                SubFinalizer = new ScopableBindingFinalizer(
                    BindInfo, SingletonTypes.ToGameObject, gameObjectInfo,
                    (container, type) => new AddToNewGameObjectComponentProvider(
                        container,
                        type,
                        BindInfo.ConcreteIdentifier,
                        BindInfo.Arguments,
                        gameObjectInfo));
            }

            return(new GameObjectNameGroupNameScopeArgBinder(BindInfo, gameObjectInfo));
        }
Exemple #2
0
        public GameObjectNameGroupNameScopeArgBinder FromPrefabResource(string resourcePath)
        {
            BindingUtil.AssertIsValidResourcePath(resourcePath);
            BindingUtil.AssertIsAbstractOrComponentOrGameObject(AllParentTypes);

            var gameObjectInfo = new GameObjectCreationParameters();

            SubFinalizer = new PrefabResourceBindingFinalizer(
                BindInfo, gameObjectInfo, resourcePath);

            return(new GameObjectNameGroupNameScopeArgBinder(BindInfo, gameObjectInfo));
        }
Exemple #3
0
        public GameObjectNameGroupNameScopeArgBinder FromPrefab(UnityEngine.Object prefab)
        {
            BindingUtil.AssertIsValidPrefab(prefab);
            BindingUtil.AssertIsAbstractOrComponentOrGameObject(AllParentTypes);

            var gameObjectInfo = new GameObjectCreationParameters();

            SubFinalizer = new PrefabBindingFinalizer(
                BindInfo, gameObjectInfo, prefab);

            return(new GameObjectNameGroupNameScopeArgBinder(BindInfo, gameObjectInfo));
        }