public InstanceSingletonProvider(
            InstanceSingletonLazyCreator lazyCreator,
            SingletonRegistry singletonRegistry, SingletonId id)
        {
            _singletonRegistry = singletonRegistry;
            _lazyCreator       = lazyCreator;
            _id = id;

            Init();
        }
Exemplo n.º 2
0
        public InstanceSingletonProvider(
            InstanceSingletonLazyCreator lazyCreator,
            SingletonRegistry singletonRegistry, SingletonId id)
        {
            _singletonRegistry = singletonRegistry;
            _lazyCreator = lazyCreator;
            _id = id;

            Init();
        }
        InstanceSingletonLazyCreator AddCreator(SingletonId id, object instance)
        {
            InstanceSingletonLazyCreator creator;

            if (_creators.TryGetValue(id, out creator))
            {
                if (!ReferenceEquals(instance, creator.Instance))
                {
                    throw new ZenjectBindException(
                        "Cannot use 'ToSingleInstance' with multiple different instances!");
                }
            }
            else
            {
                creator = new InstanceSingletonLazyCreator(
                    id, this, _container, instance);
                _creators.Add(id, creator);
            }

            return creator;
        }
Exemplo n.º 4
0
        InstanceSingletonLazyCreator AddCreator(SingletonId id, object instance)
        {
            InstanceSingletonLazyCreator creator;

            if (_creators.TryGetValue(id, out creator))
            {
                if (!ReferenceEquals(instance, creator.Instance))
                {
                    throw new ZenjectBindException(
                              "Cannot use 'ToSingleInstance' with multiple different instances!");
                }
            }
            else
            {
                creator = new InstanceSingletonLazyCreator(
                    id, this, _container, instance);
                _creators.Add(id, creator);
            }

            return(creator);
        }