protected override BuildPlan MakeConstructPlan(IEnumerable <MethodParameterInjectionPoint> injects) { var paramInjects = injects.GroupBy(x => x.Member) .Select(x => x.OrderBy(i => i.Position).ToArray()) .DefaultIfEmpty(new MethodParameterInjectionPoint[0]) .First(); if (Mixins.Any()) // todo: interceptors { return(context => { var paramVals = paramInjects.Select(p => p.GetValue(context)).ToArray(); var mixinObjects = (from mixin in Mixins let reference = Manager.GetReference(mixin, context, mixin.InterfaceTypes) from interfaceType in mixin.InterfaceTypes select new { interfaceType, reference }) .ToDictionary(x => x.interfaceType, x => x.reference); return CormoProxyGenerator.CreateMixins(Type, mixinObjects, paramVals); }); } return(context => { var paramVals = paramInjects.Select(p => p.GetValue(context)).ToArray(); return Activator.CreateInstance(Type, paramVals); }); }
protected override BuildPlan MakeConstructPlan() { var mixins = Manager.GetMixins(this); // todo: preconstruct/dispose intercetor var aroundMethodInterceptors = GetInterceptors(typeof(IAroundInvokeInterceptor)).GroupBy(x => x.Key) .Select(x => new { method = x.Key, interceptors = x.SelectMany(g => g.Value).ToArray() }) .ToArray(); if (mixins.Any() || aroundMethodInterceptors.Any()) { return(context => { var paramVals = InjectableConstructor.GetParameterValues(context); var mixinObjects = (from mixin in mixins let reference = Manager.GetReference(mixin, context, mixin.InterfaceTypes) from interfaceType in mixin.InterfaceTypes select new { interfaceType, reference }) .ToDictionary(x => x.interfaceType, x => x.reference); var interceptorHandlers = aroundMethodInterceptors .ToDictionary(x => x.method, x => new InterceptorMethodHandler(Manager, x.method, x.interceptors, context)); return CormoProxyGenerator.CreateComponentProxy(Type, mixinObjects, interceptorHandlers, paramVals); }); } return(InjectableConstructor.Invoke); }