예제 #1
0
        public PrefabResourceSingletonProvider CreateProvider(
            string concreteIdentifier, Type concreteType, string resourcePath)
        {
            var id      = new PrefabResourceSingletonId(concreteIdentifier, resourcePath);
            var creator = AddCreator(id);

            return(new PrefabResourceSingletonProvider(
                       id, concreteType, creator, _singletonRegistry, this));
        }
        public PrefabResourceSingletonLazyCreator(
            DiContainer container, PrefabResourceSingletonProviderCreator owner,
            PrefabResourceSingletonId id)
        {
            _container = container;
            _owner     = owner;
            _id        = id;

            Assert.IsNotNull(id.ResourcePath);
        }
예제 #3
0
        PrefabResourceSingletonLazyCreator AddCreator(PrefabResourceSingletonId id)
        {
            PrefabResourceSingletonLazyCreator creator;

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

            return(creator);
        }
        public PrefabResourceSingletonProvider(
            PrefabResourceSingletonId resourceId, Type componentType,
            PrefabResourceSingletonLazyCreator lazyCreator,
            SingletonRegistry singletonRegistry,
            PrefabResourceSingletonProviderCreator owner)
        {
            _owner = owner;
            Assert.That(componentType.DerivesFromOrEqual <Component>());

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

            Init();
        }
예제 #5
0
        public void RemoveCreator(PrefabResourceSingletonId id)
        {
            bool success = _creators.Remove(id);

            Assert.That(success);
        }