From ecd9813f8a1eaf24bffe02a922fa97d1a507cba5 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 20:16:48 +0100 Subject: [PATCH] Code inspections --- Meade.net/LocalServer.cs | 14 ++-- Meade.net/Properties/Resources.Designer.cs | 88 ++++++++++++++++------ Meade.net/Properties/Resources.resx | 17 +++++ 3 files changed, 90 insertions(+), 29 deletions(-) diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index 8563ba4..ffbcb70 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -23,6 +23,7 @@ using System.Runtime.InteropServices; using System.Security.Principal; using System.Threading; using System.Windows.Forms; +using ASCOM.Meade.net.Properties; using ASCOM.Utilities; using Microsoft.Win32; @@ -259,7 +260,7 @@ namespace ASCOM.Meade.net } catch (Exception e) { - MessageBox.Show($"Failed to load served COM class assembly {fi.Name} - {e.Message}", + MessageBox.Show(string.Format(Resources.Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_, fi.Name, e.Message), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } @@ -297,7 +298,7 @@ namespace ASCOM.Meade.net try { Process.Start(si); } catch (Win32Exception) { - MessageBox.Show($"The {DriverName} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DriverName, MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show(string.Format(Resources.Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_, DriverName, (arg == "/register" ? "registered" : "unregistered")), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { @@ -358,7 +359,7 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - MessageBox.Show($"Error while registering the server:\n{ex}", + MessageBox.Show(string.Format(Resources.Server_RegisterObjects_, ex), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } @@ -424,7 +425,7 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - MessageBox.Show($"Error while registering the server:\n{ex}", + MessageBox.Show(string.Format(Resources.Server_RegisterObjects_, ex), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); bFail = true; } @@ -513,7 +514,7 @@ namespace ASCOM.Meade.net _sClassFactories.Add(factory); if (!factory.RegisterClassObject()) { - MessageBox.Show("Failed to register class factory for " + type.Name, + MessageBox.Show(string.Format(Resources.Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_, type.Name), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } @@ -569,7 +570,8 @@ namespace ASCOM.Meade.net break; default: - MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding", + MessageBox.Show( + string.Format(Resources.Server_ProcessArguments_, args[0]), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; } diff --git a/Meade.net/Properties/Resources.Designer.cs b/Meade.net/Properties/Resources.Designer.cs index 71e56bc..29dff78 100644 --- a/Meade.net/Properties/Resources.Designer.cs +++ b/Meade.net/Properties/Resources.Designer.cs @@ -8,16 +8,10 @@ // //------------------------------------------------------------------------------ -using System.CodeDom.Compiler; -using System.ComponentModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Globalization; -using System.Resources; -using System.Runtime.CompilerServices; - namespace ASCOM.Meade.net.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -25,27 +19,27 @@ namespace ASCOM.Meade.net.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [DebuggerNonUserCode()] - [CompilerGenerated()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { - private static ResourceManager resourceMan; + private static global::System.Resources.ResourceManager resourceMan; - private static CultureInfo resourceCulture; + private static global::System.Globalization.CultureInfo resourceCulture; - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - internal static ResourceManager ResourceManager { + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { get { - if (ReferenceEquals(resourceMan, null)) { - ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -56,8 +50,8 @@ namespace ASCOM.Meade.net.Properties { /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - internal static CultureInfo Culture { + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -69,10 +63,58 @@ namespace ASCOM.Meade.net.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static Bitmap ASCOM { + internal static System.Drawing.Bitmap ASCOM { get { object obj = ResourceManager.GetObject("ASCOM", resourceCulture); - return ((Bitmap)(obj)); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized string similar to The {0} was not {1} because you did not allow it.. + /// + internal static string Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_ { + get { + return ResourceManager.GetString("Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Failed to load served COM class assembly {0} - {1}. + /// + internal static string Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_ { + get { + return ResourceManager.GetString("Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_" + + "", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unknown argument: {0} + ///Valid are : -register, -unregister and -embedding. + /// + internal static string Server_ProcessArguments_ { + get { + return ResourceManager.GetString("Server_ProcessArguments_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Failed to register class factory for {0}. + /// + internal static string Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_ { + get { + return ResourceManager.GetString("Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Error while registering the server: + ///{0}. + /// + internal static string Server_RegisterObjects_ { + get { + return ResourceManager.GetString("Server_RegisterObjects_", resourceCulture); } } } diff --git a/Meade.net/Properties/Resources.resx b/Meade.net/Properties/Resources.resx index f4cef88..eeb7461 100644 --- a/Meade.net/Properties/Resources.resx +++ b/Meade.net/Properties/Resources.resx @@ -121,4 +121,21 @@ ..\ASCOM.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Unknown argument: {0} +Valid are : -register, -unregister and -embedding + + + Failed to register class factory for {0} + + + Error while registering the server: +{0} + + + The {0} was not {1} because you did not allow it. + + + Failed to load served COM class assembly {0} - {1} + \ No newline at end of file