Esempio n. 1
0
        public ProviderBase CreateProvider(
            string concreteIdentifier, Type componentType, GameObject gameObject)
        {
            var id          = new MonoBehaviourSingletonId(componentType, concreteIdentifier, gameObject);
            var lazyCreator = AddCreator(id);

            return(new MonoBehaviourSingletonProvider(
                       id, componentType, lazyCreator, _singletonRegistry, this));
        }
        public MonoBehaviourSingletonLazyCreator(
            DiContainer container, MonoBehaviourSingletonProviderCreator owner,
            MonoBehaviourSingletonId id)
        {
            Assert.That(id.ConcreteType.DerivesFromOrEqual <Component>());

            _container = container;
            _owner     = owner;
            _id        = id;
        }
Esempio n. 3
0
        MonoBehaviourSingletonLazyCreator AddCreator(MonoBehaviourSingletonId id)
        {
            MonoBehaviourSingletonLazyCreator creator;

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

            return(creator);
        }
        public MonoBehaviourSingletonProvider(
            MonoBehaviourSingletonId monoBehaviourId,
            Type componentType,
            MonoBehaviourSingletonLazyCreator lazyCreator,
            SingletonRegistry singletonRegistry,
            MonoBehaviourSingletonProviderCreator owner)
        {
            _owner = owner;
            Assert.That(componentType.DerivesFromOrEqual <Component>());

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

            Init();
        }
Esempio n. 5
0
        internal void RemoveCreator(MonoBehaviourSingletonId id)
        {
            bool success = _creators.Remove(id);

            Assert.That(success);
        }