private void InvokeConfigurationInternal(BuildContext.BaseBuildContext context) { _readOnly = true; var configureMethods = context.CreateConfigureCollection(GetType()).ToList(); // Clear current configurations _configurations.Clear(); var usedTargetNames = new Dictionary <string, ITarget>(); foreach (ITarget target in Targets.TargetObjects) { string targetString = target.GetTargetString(); if (usedTargetNames.ContainsKey(targetString)) { ITarget otherTarget = usedTargetNames[targetString]; string diffString = Util.MakeDifferenceString(target, otherTarget); throw new Error("Target string \"" + target + "\" is present twice; difference is: " + diffString); } usedTargetNames.Add(targetString, target); TConfiguration conf = Activator.CreateInstance(ConfigurationType) as TConfiguration; conf.Construct(this, target); _configurations.Add(conf); var param = new object[] { conf, target }; foreach (MethodInfo method in configureMethods) { if (!FilterMethodForTarget(method, target)) { continue; } try { method.Invoke(this, param); } catch (Exception e) { // SMARTLINE TODO: Should be method line throw new Error(e, "Error executing [Configure(...)] method: {0} {1}; are the method arguments of good types?", GetType().Name, method.ToString()); } } } _readOnly = false; }