public PrefabSingletonLazyCreator(
            DiContainer container, PrefabSingletonProviderMap owner, PrefabSingletonId id)
        {
            _container = container;
            _owner     = owner;
            _id        = id;

            Assert.That(id.Prefab != null || id.ResourcePath != null);
        }
Esempio n. 2
0
        public PrefabSingletonProvider CreateProvider(
            string concreteIdentifier, Type concreteType, GameObject prefab)
        {
            var id      = new PrefabSingletonId(concreteIdentifier, prefab);
            var creator = AddCreator(id);

            return(new PrefabSingletonProvider(
                       id, concreteType, creator, _singletonRegistry, this));
        }
        public PrefabSingletonLazyCreator(
            DiContainer container, PrefabSingletonProviderCreator owner,
            PrefabSingletonId id)
        {
            _container = container;
            _owner     = owner;
            _id        = id;

            Assert.IsNotNull(id.Prefab);
        }
Esempio n. 4
0
        PrefabSingletonLazyCreator AddCreator(PrefabSingletonId id)
        {
            PrefabSingletonLazyCreator creator;

            if (!_creators.TryGetValue(id, out creator))
            {
                creator = new PrefabSingletonLazyCreator(_container, this, id);
                _creators.Add(id, creator);
            }

            return(creator);
        }
        public PrefabSingletonProvider(
            PrefabSingletonId prefabId, Type componentType,
            PrefabSingletonLazyCreator lazyCreator,
            SingletonRegistry singletonRegistry,
            PrefabSingletonProviderCreator owner)
        {
            _owner = owner;
            Assert.That(componentType.DerivesFromOrEqual <Component>());

            _singletonRegistry = singletonRegistry;
            _lazyCreator       = lazyCreator;
            _componentType     = componentType;
            _prefabId          = prefabId;
            _singletonId       = new SingletonId(componentType, prefabId.ConcreteIdentifier);

            Init();
        }
        internal void RemoveCreator(PrefabSingletonId id)
        {
            bool success = _creators.Remove(id);

            Assert.That(success);
        }