public static void ResolveAllWantedCrossReferences(FailMode failReportMode) { DeepProfiler.Start("ResolveAllWantedCrossReferences"); try { HashSet <WantedRef> resolvedRefs = new HashSet <WantedRef>(); object resolvedRefsLock = new object(); DeepProfiler.enabled = false; GenThreading.ParallelForEach(wantedRefs, delegate(WantedRef wantedRef) { if (wantedRef.TryResolve(failReportMode)) { lock (resolvedRefsLock) { resolvedRefs.Add(wantedRef); } } }); foreach (WantedRef item in resolvedRefs) { item.Apply(); } wantedRefs.RemoveAll((WantedRef x) => resolvedRefs.Contains(x)); DeepProfiler.enabled = true; } finally { DeepProfiler.End(); } }
public static void ResolveAllReferences(bool onlyExactlyMyType = true, bool parallel = false) { DeepProfiler.Start("SetIndices"); try { SetIndices(); } finally { DeepProfiler.End(); } DeepProfiler.Start("ResolveAllReferences " + typeof(T).FullName); try { Action <T> action = delegate(T def) { if (!onlyExactlyMyType || !(def.GetType() != typeof(T))) { DeepProfiler.Start("Resolver call"); try { def.ResolveReferences(); } catch (Exception ex) { Log.Error("Error while resolving references for def " + def + ": " + ex); } finally { DeepProfiler.End(); } } }; if (parallel) { GenThreading.ParallelForEach(defsList, action); } else { for (int i = 0; i < defsList.Count; i++) { action(defsList[i]); } } } finally { DeepProfiler.End(); } DeepProfiler.Start("SetIndices"); try { SetIndices(); } finally { DeepProfiler.End(); } }