Code inspections

This commit is contained in:
2019-09-29 20:16:48 +01:00
parent 0e0ea2d2b0
commit ecd9813f8a
3 changed files with 90 additions and 29 deletions
+8 -6
View File
@@ -23,6 +23,7 @@ using System.Runtime.InteropServices;
using System.Security.Principal; using System.Security.Principal;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using ASCOM.Meade.net.Properties;
using ASCOM.Utilities; using ASCOM.Utilities;
using Microsoft.Win32; using Microsoft.Win32;
@@ -259,7 +260,7 @@ namespace ASCOM.Meade.net
} }
catch (Exception e) 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); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false; return false;
} }
@@ -297,7 +298,7 @@ namespace ASCOM.Meade.net
try { Process.Start(si); } try { Process.Start(si); }
catch (Win32Exception) 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) catch (Exception ex)
{ {
@@ -358,7 +359,7 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) 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); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return; return;
} }
@@ -424,7 +425,7 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) 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); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
bFail = true; bFail = true;
} }
@@ -513,7 +514,7 @@ namespace ASCOM.Meade.net
_sClassFactories.Add(factory); _sClassFactories.Add(factory);
if (!factory.RegisterClassObject()) 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); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false; return false;
} }
@@ -569,7 +570,8 @@ namespace ASCOM.Meade.net
break; break;
default: 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); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break; break;
} }
+65 -23
View File
@@ -8,16 +8,10 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
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 { namespace ASCOM.Meade.net.Properties {
using System;
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
@@ -25,27 +19,27 @@ namespace ASCOM.Meade.net.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[CompilerGenerated()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { 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() { internal Resources() {
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
@@ -56,8 +50,8 @@ namespace ASCOM.Meade.net.Properties {
/// Overrides the current thread's CurrentUICulture property for all /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
@@ -69,10 +63,58 @@ namespace ASCOM.Meade.net.Properties {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static Bitmap ASCOM { internal static System.Drawing.Bitmap ASCOM {
get { get {
object obj = ResourceManager.GetObject("ASCOM", resourceCulture); object obj = ResourceManager.GetObject("ASCOM", resourceCulture);
return ((Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to The {0} was not {1} because you did not allow it..
/// </summary>
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);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to load served COM class assembly {0} - {1}.
/// </summary>
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);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown argument: {0}
///Valid are : -register, -unregister and -embedding.
/// </summary>
internal static string Server_ProcessArguments_ {
get {
return ResourceManager.GetString("Server_ProcessArguments_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to register class factory for {0}.
/// </summary>
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);
}
}
/// <summary>
/// Looks up a localized string similar to Error while registering the server:
///{0}.
/// </summary>
internal static string Server_RegisterObjects_ {
get {
return ResourceManager.GetString("Server_RegisterObjects_", resourceCulture);
} }
} }
} }
+17
View File
@@ -121,4 +121,21 @@
<data name="ASCOM" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="ASCOM" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ASCOM.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\ASCOM.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Server_ProcessArguments_" xml:space="preserve">
<value>Unknown argument: {0}
Valid are : -register, -unregister and -embedding</value>
</data>
<data name="Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_" xml:space="preserve">
<value>Failed to register class factory for {0}</value>
</data>
<data name="Server_RegisterObjects_" xml:space="preserve">
<value>Error while registering the server:
{0}</value>
</data>
<data name="Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_" xml:space="preserve">
<value>The {0} was not {1} because you did not allow it.</value>
</data>
<data name="Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_" xml:space="preserve">
<value>Failed to load served COM class assembly {0} - {1}</value>
</data>
</root> </root>