diff --git a/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs b/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs index 6489202..461370e 100644 --- a/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs +++ b/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs @@ -17,6 +17,11 @@ namespace EveOPreview public void SetupExceptionHandlers() { + if (System.Diagnostics.Debugger.IsAttached) + { + return; + } + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += delegate (Object sender, ThreadExceptionEventArgs e) { diff --git a/Eve-O-Preview/ApplicationBase/IIocContainer.cs b/Eve-O-Preview/ApplicationBase/IIocContainer.cs index 273de67..e5b694c 100644 --- a/Eve-O-Preview/ApplicationBase/IIocContainer.cs +++ b/Eve-O-Preview/ApplicationBase/IIocContainer.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; +using System.Reflection; namespace EveOPreview { @@ -8,11 +10,17 @@ namespace EveOPreview /// public interface IIocContainer { - void Register() where TImplementation : TService; + void Register() + where TImplementation : TService; + void Register(Type serviceType, Assembly container); void Register(); - void RegisterInstance(T instance); - TService Resolve(); - bool IsRegistered(); + void Register(Expression> factory); void Register(Expression> factory); + void RegisterInstance(TService instance); + TService Resolve(); + IEnumerable ResolveAll(); + object Resolve(Type serviceType); + IEnumerable ResolveAll(Type serviceType); + bool IsRegistered(); } } \ No newline at end of file diff --git a/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs b/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs index 73567c9..3cceb94 100644 --- a/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs +++ b/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; +using System.Reflection; using LightInject; namespace EveOPreview @@ -19,9 +21,38 @@ namespace EveOPreview return this._container.CanGetInstance(typeof(TService), ""); } + public void Register(Type serviceType, Assembly container) + { + if (!serviceType.IsInterface) + { + this._container.Register(serviceType, new PerContainerLifetime()); + return; + } + + if (serviceType.IsInterface && serviceType.IsGenericType) + { + this._container.RegisterAssembly(container, (st, it) => st.IsConstructedGenericType && st.GetGenericTypeDefinition() == serviceType); + } + else + { + foreach (TypeInfo implementationType in container.DefinedTypes) + { + if (!implementationType.IsClass || implementationType.IsAbstract) + { + continue; + } + + if (serviceType.IsAssignableFrom(implementationType)) + { + this._container.Register(serviceType, implementationType, new PerContainerLifetime()); + } + } + } + } + public void Register() { - this._container.Register(); + this.Register(typeof(TService), typeof(TService).Assembly); } public void Register() @@ -30,12 +61,17 @@ namespace EveOPreview this._container.Register(); } + public void Register(Expression> factory) + { + this._container.Register(f => factory); + } + public void Register(Expression> factory) { this._container.Register(f => factory); } - public void RegisterInstance(T instance) + public void RegisterInstance(TService instance) { this._container.RegisterInstance(instance); } @@ -44,5 +80,20 @@ namespace EveOPreview { return this._container.GetInstance(); } + + public IEnumerable ResolveAll() + { + return this._container.GetAllInstances(); + } + + public object Resolve(Type serviceType) + { + return this._container.GetInstance(serviceType); + } + + public IEnumerable ResolveAll(Type serviceType) + { + return this._container.GetAllInstances(serviceType); + } } } \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/ConfigurationStorage.cs b/Eve-O-Preview/Configuration/ConfigurationStorage.cs index f6452db..78fce2f 100644 --- a/Eve-O-Preview/Configuration/ConfigurationStorage.cs +++ b/Eve-O-Preview/Configuration/ConfigurationStorage.cs @@ -8,12 +8,12 @@ namespace EveOPreview.Configuration private const string ConfigurationFileName = "EVE-O Preview.json"; private readonly IAppConfig _appConfig; - private readonly IThumbnailConfig _thumbnailConfig; + private readonly IThumbnailConfiguration _thumbnailConfiguration; - public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfig thumbnailConfig) + public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfiguration thumbnailConfiguration) { this._appConfig = appConfig; - this._thumbnailConfig = thumbnailConfig; + this._thumbnailConfiguration = thumbnailConfiguration; } public void Load() @@ -27,15 +27,15 @@ namespace EveOPreview.Configuration string rawData = File.ReadAllText(filename); - JsonConvert.PopulateObject(rawData, this._thumbnailConfig); + JsonConvert.PopulateObject(rawData, this._thumbnailConfiguration); // Validate data after loading it - this._thumbnailConfig.ApplyRestrictions(); + this._thumbnailConfiguration.ApplyRestrictions(); } public void Save() { - string rawData = JsonConvert.SerializeObject(this._thumbnailConfig, Formatting.Indented); + string rawData = JsonConvert.SerializeObject(this._thumbnailConfiguration, Formatting.Indented); File.WriteAllText(this.GetConfigFileName(), rawData); } diff --git a/Eve-O-Preview/Configuration/IThumbnailConfig.cs b/Eve-O-Preview/Configuration/IThumbnailConfiguration.cs similarity index 90% rename from Eve-O-Preview/Configuration/IThumbnailConfig.cs rename to Eve-O-Preview/Configuration/IThumbnailConfiguration.cs index f3571d7..f5308eb 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/IThumbnailConfiguration.cs @@ -3,10 +3,7 @@ using System.Windows.Forms; namespace EveOPreview.Configuration { - /// - /// Thumbnails Manager configuration - /// - public interface IThumbnailConfig + public interface IThumbnailConfiguration { bool MinimizeToTray { get; set; } int ThumbnailRefreshPeriod { get; set; } diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfiguration.cs similarity index 83% rename from Eve-O-Preview/Configuration/ThumbnailConfig.cs rename to Eve-O-Preview/Configuration/ThumbnailConfiguration.cs index 24c71f2..9a268c7 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfiguration.cs @@ -5,9 +5,9 @@ using Newtonsoft.Json; namespace EveOPreview.Configuration { - class ThumbnailConfig : IThumbnailConfig + class ThumbnailConfiguration : IThumbnailConfiguration { - public ThumbnailConfig() + public ThumbnailConfiguration() { this.MinimizeToTray = false; this.ThumbnailRefreshPeriod = 500; @@ -173,12 +173,12 @@ namespace EveOPreview.Configuration /// public void ApplyRestrictions() { - this.ThumbnailRefreshPeriod = ThumbnailConfig.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); - this.ThumbnailSize = new Size(ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), - ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); - this.ThumbnailOpacity = ThumbnailConfig.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00; - this.ThumbnailZoomFactor = ThumbnailConfig.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10); - this.ActiveClientHighlightThickness = ThumbnailConfig.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6); + this.ThumbnailRefreshPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); + this.ThumbnailSize = new Size(ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), + ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); + this.ThumbnailOpacity = ThumbnailConfiguration.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00; + this.ThumbnailZoomFactor = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10); + this.ActiveClientHighlightThickness = ThumbnailConfiguration.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6); } private static int ApplyRestrictions(int value, int minimum, int maximum) diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index ffa7348..cd4ae53 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -10,7 +10,7 @@ Properties EveOPreview Eve-O Preview - v4.5.2 + v4.6 @@ -83,9 +83,12 @@ ..\packages\LightInject.5.1.2\lib\net452\LightInject.dll True - - R:\eve-o-preview\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\MediatR.4.0.1\lib\net45\MediatR.dll + + + + ..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll @@ -108,59 +111,75 @@ - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - + + + - + Form - + MainForm.cs - - - - + + + + Form - + ThumbnailOverlay.cs - + Designer MainForm.cs - + ThumbnailOverlay.cs @@ -168,7 +187,7 @@ Resources.Designer.cs Designer - + Designer ThumbnailView.cs @@ -177,13 +196,13 @@ Resources.resx True - + Form - + ThumbnailView.cs - + @@ -203,11 +222,11 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - +