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

            Init();
        }
Пример #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;
        }
Пример #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);
        }