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; }
public Builder( BuildContext.BaseBuildContext context, bool multithreaded, bool dumpDependencyGraph, bool cleanBlobsOnly, bool blobOnly, bool skipInvalidPath, bool diagnostics, Func <IGeneratorManager> getGeneratorsManagerCallBack, HashSet <string> defines) { Context = context; Arguments = new Arguments(this); _multithreaded = multithreaded; DumpDependencyGraph = dumpDependencyGraph; _cleanBlobsOnly = cleanBlobsOnly; BlobOnly = blobOnly; Diagnostics = diagnostics; SkipInvalidPath = skipInvalidPath; _getGeneratorsManagerCallBack = getGeneratorsManagerCallBack; _getGeneratorsManagerCallBack().InitializeBuilder(this); Trace.Assert(Instance == null); Instance = this; _builderExt = new BuilderExtension(this); Defines = defines ?? new HashSet <string>(); AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; if (Diagnostics) { EventPostGeneration += LogUnusedProjectConfigurations; } if (_multithreaded) { _tasks = new ThreadPool(); int nbThreads = Environment.ProcessorCount; _tasks.Start(nbThreads); } }