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

            Init();
        }
        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;
        }
Beispiel #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);
        }