/// <summary> /// Positions the assembly browser of Reflector on the element /// that best matches the parameters contained in the <paramref name="element"/> parameter /// and brings the Reflector window to front if at least the specified assembly was found. /// </summary> /// <param name="element">A <see cref="CodeElementInfo"/> object that describes the element to go to.</param> /// <exception cref="ArgumentNullException">The <paramref name="element"/> parameter is <c>null</c>.</exception> public void GoTo(CodeElementInfo element) { if (element == null) { throw new ArgumentNullException("element"); } if (!this.IsReady) { throw new InvalidOperationException("The service is not ready."); } WindowManager.Content.BeginInvoke(new Action <CodeElementInfo>(GoToInternal), new object[] { element }); }
void GoToInternal(CodeElementInfo element) { if (element == null) { throw new ArgumentNullException("element"); } IAssembly asm = AssemblyManager.LoadFile(element.AssemblyLocation); if (asm == null) { return; } // Force reload of the assembly if it has changed since start of Service DateTime tNew = GetLastWriteTimeSafe(element.AssemblyLocation); DateTime tOld; if (this.assemblyLastWriteTimes.TryGetValue(element.AssemblyLocation, out tOld)) { if (!tNew.Equals(tOld)) { AssemblyManager.Unload(asm); asm = AssemblyManager.LoadFile(element.AssemblyLocation); if (asm == null) { return; } } } this.assemblyLastWriteTimes[element.AssemblyLocation] = tNew; AssemblyBrowser.ActiveItem = (new CodeElementFinder(element)).Find(asm); WindowManager.Activate(); Form topForm = WindowManager.Content.FindForm(); if (topForm != null) { // Force the Reflector window to the top if (topForm.WindowState == FormWindowState.Minimized) { topForm.WindowState = FormWindowState.Normal; } topForm.TopMost = true; topForm.TopMost = false; } }
internal CodeElementFinder(CodeElementInfo element) { this.element = element; }