private TransientBuilder <T> GetBuilder <T>(Type mixinType)
        {
            TransientFinder finder = this.moduleInstance.FindCompositeModel(mixinType);

            if (finder.Model == null)
            {
                throw new Exception("Composite not found");
            }

            return(new TransientBuilderInstance <T>(finder.Module, finder.Model));
        }
예제 #2
0
        public TransientFinder FindCompositeModel(Type mixinType)
        {
            TransientFinder finder;

            if (!this.transientFinders.TryGetValue(mixinType, out finder))
            {
                finder = new TransientFinder
                {
                    MixinType = mixinType
                };
                this.VisitModules(finder);
                if (finder.Model != null)
                {
                    this.transientFinders.Add(mixinType, finder);
                }
            }

            return(finder);
        }
예제 #3
0
        public object ProvideInjection(InjectionContext context, InjectionAttribute attribute, Type fieldType)
        {
            object obj = context.Uses.UseForType(fieldType);

            if (obj != null)
            {
                return(obj);
            }

            ModuleInstance moduleInstance = context.ModuleInstance;

            TransientFinder compositeFinder = moduleInstance.FindCompositeModel(fieldType);

            if (compositeFinder.Model != null)
            {
                CompositeInstance compositeInstance = compositeFinder.Model.NewCompositeInstance(moduleInstance, context.Uses, context.State);
                context.Uses.Use(compositeInstance);
                return(compositeInstance.Proxy);
            }

            return(null);
        }