Exemplo n.º 1
0
        protected override BuildPlan GetBuildPlan()
        {
            var paramInject   = InjectionPoints.OfType <MethodParameterInjectionPoint>().ToArray();
            var constructPlan = MakeConstructPlan(paramInject.Where(x => x.IsConstructor));
            var methodInject  = InjectMethods(paramInject.Where(x => !x.IsConstructor)).ToArray();
            var otherInjects  = InjectionPoints.Except(paramInject).Cast <IWeldInjetionPoint>();

            return(context =>
            {
                var instance = constructPlan(context);
                context.Push(instance);

                foreach (var i in otherInjects)
                {
                    i.Inject(instance, context);
                }
                foreach (var i in methodInject)
                {
                    i(instance, context);
                }
                foreach (var post in PostConstructs)
                {
                    post.Invoke(instance, new object[0]);
                }

                return instance;
            });
        }
Exemplo n.º 2
0
        protected override BuildPlan GetBuildPlan()
        {
            var paramInjects = InjectionPoints
                               .OfType <MethodParameterInjectionPoint>()
                               .Where(x => x.Member == _method)
                               .OrderBy(x => x.Position).ToArray();

            return(context =>
            {
                var containingObject = Manager.GetReference(DeclaringComponent, context);
                var paramVals = paramInjects.Select(p => p.GetValue(context)).ToArray();

                return _method.Invoke(containingObject, paramVals);
            });
        }