public IProvider CreateProvider(
            UnityEngine.Object prefab, Type resultType, GameObjectCreationParameters gameObjectBindInfo,
            List <TypeValuePair> extraArguments, object concreteIdentifier, Func <Type, IPrefabInstantiator, IProvider> providerFactory)
        {
            IPrefabInstantiator creator;

            var prefabId = new PrefabId(concreteIdentifier, prefab);

            _markRegistry.MarkSingleton(
                resultType, concreteIdentifier, SingletonTypes.FromPrefab);

            if (_prefabCreators.TryGetValue(prefabId, out creator))
            {
                // TODO: Check the arguments are the same?
                Assert.That(creator.ExtraArguments.IsEmpty() && extraArguments.IsEmpty(),
                            "Ambiguous creation parameters (arguments) when using ToPrefab with AsSingle");

                Assert.IsEqual(creator.GameObjectCreationParameters, gameObjectBindInfo,
                               "Ambiguous creation parameters (game object naming/parent info) when using ToPrefab with AsSingle");
            }
            else
            {
                creator = new PrefabInstantiatorCached(
                    new PrefabInstantiator(
                        _container, gameObjectBindInfo, resultType, extraArguments, new PrefabProvider(prefab)));

                _prefabCreators.Add(prefabId, creator);
            }

            if (resultType == typeof(GameObject))
            {
                return(new PrefabGameObjectProvider(creator));
            }

            return(providerFactory(resultType, creator));
        }
Пример #2
0
 public bool Equals(GameObjectCreationParameters that)
 {
     return(this == that);
 }
 public CreatorInfo(
     GameObjectCreationParameters gameObjectBindInfo, ISubContainerCreator creator)
 {
     GameObjectCreationParameters = gameObjectBindInfo;
     Creator = creator;
 }
Пример #4
0
 public EmptyGameObjectProvider(
     DiContainer container, GameObjectCreationParameters gameObjectBindInfo)
 {
     _gameObjectBindInfo = gameObjectBindInfo;
     _container          = container;
 }