|
|
|
@ -16,15 +16,24 @@ namespace Reflector.IpcServer.AddIn |
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Provides the ability to remote-control Reflector.
|
|
|
|
/// Provides the ability to remote-control Reflector.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public sealed class ReflectorService : MarshalByRefObject, IReflectorService |
|
|
|
public sealed class ReflectorService : MarshalByRefObject, IReflectorService, IDisposable |
|
|
|
{ |
|
|
|
{ |
|
|
|
readonly IServiceProvider serviceProvider; |
|
|
|
readonly IServiceProvider serviceProvider; |
|
|
|
readonly Dictionary<string, DateTime> assemblyLastWriteTimes = new Dictionary<string, DateTime>(StringComparer.InvariantCultureIgnoreCase); |
|
|
|
readonly Dictionary<string, DateTime> assemblyLastWriteTimes = new Dictionary<string, DateTime>(StringComparer.InvariantCultureIgnoreCase); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime lastAssemblyLoadedAt = DateTime.MinValue; |
|
|
|
|
|
|
|
|
|
|
|
public ReflectorService(IServiceProvider serviceProvider) |
|
|
|
public ReflectorService(IServiceProvider serviceProvider) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); |
|
|
|
if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); |
|
|
|
this.serviceProvider = serviceProvider; |
|
|
|
this.serviceProvider = serviceProvider; |
|
|
|
|
|
|
|
this.AssemblyManager.AssemblyLoaded += this.AssemblyLoaded; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.AssemblyManager.AssemblyLoaded -= this.AssemblyLoaded; |
|
|
|
|
|
|
|
this.assemblyLastWriteTimes.Clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
@ -37,6 +46,18 @@ namespace Reflector.IpcServer.AddIn |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsReady { |
|
|
|
|
|
|
|
get { |
|
|
|
|
|
|
|
return this.lastAssemblyLoadedAt != DateTime.MinValue && |
|
|
|
|
|
|
|
(DateTime.UtcNow - this.lastAssemblyLoadedAt).TotalSeconds > 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssemblyLoaded(object sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.lastAssemblyLoadedAt = DateTime.UtcNow; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************************************************************************************
|
|
|
|
// ********************************************************************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
T GetService<T>() |
|
|
|
T GetService<T>() |
|
|
|
@ -66,6 +87,7 @@ namespace Reflector.IpcServer.AddIn |
|
|
|
public void GoTo(CodeElementInfo element) |
|
|
|
public void GoTo(CodeElementInfo element) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (element == null) throw new ArgumentNullException("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), |
|
|
|
WindowManager.Content.BeginInvoke(new Action<CodeElementInfo>(GoToInternal), |
|
|
|
new object[] { element }); |
|
|
|
new object[] { element }); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -97,6 +119,9 @@ namespace Reflector.IpcServer.AddIn |
|
|
|
Form topForm = WindowManager.Content.FindForm(); |
|
|
|
Form topForm = WindowManager.Content.FindForm(); |
|
|
|
if (topForm != null) { |
|
|
|
if (topForm != null) { |
|
|
|
// Force the Reflector window to the top
|
|
|
|
// Force the Reflector window to the top
|
|
|
|
|
|
|
|
if (topForm.WindowState == FormWindowState.Minimized) { |
|
|
|
|
|
|
|
topForm.WindowState = FormWindowState.Normal; |
|
|
|
|
|
|
|
} |
|
|
|
topForm.TopMost = true; |
|
|
|
topForm.TopMost = true; |
|
|
|
topForm.TopMost = false; |
|
|
|
topForm.TopMost = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|