Beispiel #1
0
        public virtual IRegistration Build()
        {
            var injector = InjectorCache.GetOrBuild(ImplementationType);

            return(new Registration(
                       ImplementationType,
                       Lifetime,
                       InterfaceTypes,
                       Parameters,
                       injector));
        }
Beispiel #2
0
        public override IRegistration Build()
        {
            var injector = InjectorCache.GetOrBuild(ImplementationType);

            return(new SystemRegistration(
                       ImplementationType,
                       InterfaceTypes,
                       Parameters,
                       injector,
                       worldName,
                       systemGroupType));
        }
        public override IRegistration Build()
        {
            var injector    = InjectorCache.GetOrBuild(ImplementationType);
            var destination = new ComponentDestination(prefab, parent, parentFinder, gameObjectName);

            return(new ComponentRegistration(
                       ImplementationType,
                       Lifetime,
                       InterfaceTypes,
                       Parameters,
                       injector,
                       destination));
        }
Beispiel #4
0
        public void CircularDependency()
        {
            var builder = new ContainerBuilder();

            builder.Register <HasCircularDependency1>(Lifetime.Transient);
            builder.Register <HasCircularDependency2>(Lifetime.Transient);

            var injector = InjectorCache.GetOrBuild(typeof(HasCircularDependency1));

            // Only reflection mode can detect circular dependency errors at runtime.
            if (injector is ReflectionInjector)
            {
                // Assert.Throws<AggregateException>(() => builder.Build());
                Assert.Throws <VContainerException>(() => builder.Build(),
                                                    "Circular dependency detected! type: VContainer.Tests.HasCircularDependency1");
            }
        }
Beispiel #5
0
        public void Inject(object instance, params IInjectParameter[] parameters)
        {
            var injector = InjectorCache.GetOrBuild(instance.GetType());

            injector.Inject(instance, this, parameters);
        }
Beispiel #6
0
        public void Inject(object instance)
        {
            var injector = InjectorCache.GetOrBuild(instance.GetType());

            injector.Inject(instance, this, null);
        }