public void Execute(IPlan plan) { if (plan.Has<ConstructorInjectionDirective>()) { var ctor = plan.GetOne<ConstructorInjectionDirective>(); for (int i = 0; i < ctor.Targets.Length; i++) { var prm = ctor.Targets[i] as ParameterTarget; NamedAttribute named = null; if (prm != null && (named = prm.GetCustomAttributes(typeof(NamedAttribute), true) .OfType<NamedAttribute>().FirstOrDefault()) != null) { // Overwrite the target with a named one. // We just replace the target with one that appends the named attribute. ctor.Targets[i] = new ParameterTarget((MethodBase)prm.Member, new NamedParameterInfo(prm.Site, named.Name)); } } } }