From b33d1741c4e959ad9601af73b8fb0b92cd81d44b Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 4 Sep 2020 15:23:46 +0100 Subject: [PATCH] Removed the Classname static as it doesn't work as desired. Replace with a parameter on the initialise method instead. --- Meade.net.Telescope/Telescope.cs | 9 ++------- Meade.net.focuser/Focuser.cs | 13 ++++--------- Meade.net/MeadeTelescopeBase.cs | 15 ++++----------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index fc0ca39..090ac9c 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -40,11 +40,6 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Telescope : MeadeTelescopeBase, ITelescopeV3 { - static Telescope() - { - ClassName = nameof(Telescope); - } - /// /// ASCOM DeviceID (COM ProgID) for this driver. /// The DeviceID is used by ASCOM applications to load the driver at runtime. @@ -80,7 +75,7 @@ namespace ASCOM.Meade.net _astroUtilities = new AstroUtils(); // Initialise astro utilities object _astroMaths = new AstroMaths.AstroMaths(); - Initialise(); + Initialise(nameof(Telescope)); } catch (Exception e) { @@ -118,7 +113,7 @@ namespace ASCOM.Meade.net _astroUtilities = astroUtilities; // Initialise astro utilities object _astroMaths = astroMaths; - Initialise(); + Initialise(nameof(Telescope)); } private bool _isGuiding; diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 9f9c9f6..ab8220a 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -32,11 +32,6 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Focuser : MeadeTelescopeBase, IFocuserV3 { - static Focuser() - { - ClassName = nameof(Focuser); - } - /// /// ASCOM DeviceID (COM ProgID) for this driver. /// The DeviceID is used by ASCOM applications to load the driver at runtime. @@ -59,16 +54,16 @@ namespace ASCOM.Meade.net var util = new Util(); //Initialise util object _utilities = util; - Initialise(); + Initialise(nameof(Focuser)); } public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper) { _utilities = util; - Initialise(); + Initialise(nameof(Focuser)); } - + // // PUBLIC COM INTERFACE IFocuserV3 IMPLEMENTATION // @@ -427,7 +422,7 @@ namespace ASCOM.Meade.net { using (IProfileWrapper p = ProfileFactory.Create()) { - p.DeviceType = ClassName; + p.DeviceType = nameof(Focuser); if (bRegister) { p.Register(DriverId, DriverDescription); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index c8dc5b0..a3728da 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -9,13 +9,6 @@ namespace ASCOM.Meade.net [ComVisible(false)] public class MeadeTelescopeBase : ReferenceCountedObjectBase { - static MeadeTelescopeBase() - { - ClassName = nameof(MeadeTelescopeBase); - } - - public static string ClassName { get; protected set; } - /// /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// @@ -46,16 +39,16 @@ namespace ASCOM.Meade.net SharedResourcesWrapper = sharedResourcesWrapper; } - protected void Initialise() + protected void Initialise(string className) { - Tl = new TraceLogger("", $"Meade.Generic.{ClassName}"); + Tl = new TraceLogger("", $"Meade.Generic.{className}"); ReadProfile(); // Read device configuration from the ASCOM Profile store IsConnected = false; // Initialise connected to false - LogMessage(ClassName, "Completed initialisation"); - LogMessage(ClassName, $"Driver version: {DriverVersion}"); + LogMessage(className, "Completed initialisation"); + LogMessage(className, $"Driver version: {DriverVersion}"); } ///