Ejemplo n.º 1
0
        /// <inheritdoc />
        public IFactory CreateFactory()
        {
            foreach (var onCreating in OnCreatingFactory.Values)
            {
                onCreating();
            }

            foreach (var unique in _uniques.Values)
            {
                unique(_register);
            }
            _uniques.Clear(); // no point keep them around

            foreach (var builder in _builders.Values)
            {
                builder.RegisterWith(_register);
            }
            _builders.Clear(); // no point keep them around

            Configs.RegisterWith(_register);

            IFactory factory = null;

            // ReSharper disable once AccessToModifiedClosure -- on purpose
            _register.Register(_ => factory, Lifetime.Singleton);
            factory = _register.CreateFactory();
            return(factory);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public IFactory CreateFactory()
        {
            foreach (var onCreating in OnCreatingFactory.Values)
            {
                onCreating();
            }

            foreach (var unique in _uniques.Values)
            {
                unique(_register);
            }
            _uniques.Clear(); // no point keep them around

            foreach (var builder in _builders.Values)
            {
                builder.RegisterWith(_register);
            }
            _builders.Clear(); // no point keep them around

            Configs.RegisterWith(_register);

            return(_register.CreateFactory());
        }
 private void VerifyRegisteredCount(int expected)
 {
     Assert.That(register.CreateFactory().GetAllInstances <IAbstraction>().ToArray(), Has.Length.EqualTo(expected));
 }