Removed the Classname static as it doesn't work as desired. Replace with a parameter on the initialise method instead.

This commit is contained in:
2020-09-04 15:23:46 +01:00
parent d728dbe272
commit b33d1741c4
3 changed files with 10 additions and 27 deletions
+2 -7
View File
@@ -40,11 +40,6 @@ namespace ASCOM.Meade.net
[ComVisible(true)] [ComVisible(true)]
public class Telescope : MeadeTelescopeBase, ITelescopeV3 public class Telescope : MeadeTelescopeBase, ITelescopeV3
{ {
static Telescope()
{
ClassName = nameof(Telescope);
}
/// <summary> /// <summary>
/// ASCOM DeviceID (COM ProgID) for this driver. /// ASCOM DeviceID (COM ProgID) for this driver.
/// The DeviceID is used by ASCOM applications to load the driver at runtime. /// 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 _astroUtilities = new AstroUtils(); // Initialise astro utilities object
_astroMaths = new AstroMaths.AstroMaths(); _astroMaths = new AstroMaths.AstroMaths();
Initialise(); Initialise(nameof(Telescope));
} }
catch (Exception e) catch (Exception e)
{ {
@@ -118,7 +113,7 @@ namespace ASCOM.Meade.net
_astroUtilities = astroUtilities; // Initialise astro utilities object _astroUtilities = astroUtilities; // Initialise astro utilities object
_astroMaths = astroMaths; _astroMaths = astroMaths;
Initialise(); Initialise(nameof(Telescope));
} }
private bool _isGuiding; private bool _isGuiding;
+4 -9
View File
@@ -32,11 +32,6 @@ namespace ASCOM.Meade.net
[ComVisible(true)] [ComVisible(true)]
public class Focuser : MeadeTelescopeBase, IFocuserV3 public class Focuser : MeadeTelescopeBase, IFocuserV3
{ {
static Focuser()
{
ClassName = nameof(Focuser);
}
/// <summary> /// <summary>
/// ASCOM DeviceID (COM ProgID) for this driver. /// ASCOM DeviceID (COM ProgID) for this driver.
/// The DeviceID is used by ASCOM applications to load the driver at runtime. /// 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 var util = new Util(); //Initialise util object
_utilities = util; _utilities = util;
Initialise(); Initialise(nameof(Focuser));
} }
public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper) public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper)
{ {
_utilities = util; _utilities = util;
Initialise(); Initialise(nameof(Focuser));
} }
// //
// PUBLIC COM INTERFACE IFocuserV3 IMPLEMENTATION // PUBLIC COM INTERFACE IFocuserV3 IMPLEMENTATION
// //
@@ -427,7 +422,7 @@ namespace ASCOM.Meade.net
{ {
using (IProfileWrapper p = ProfileFactory.Create()) using (IProfileWrapper p = ProfileFactory.Create())
{ {
p.DeviceType = ClassName; p.DeviceType = nameof(Focuser);
if (bRegister) if (bRegister)
{ {
p.Register(DriverId, DriverDescription); p.Register(DriverId, DriverDescription);
+4 -11
View File
@@ -9,13 +9,6 @@ namespace ASCOM.Meade.net
[ComVisible(false)] [ComVisible(false)]
public class MeadeTelescopeBase : ReferenceCountedObjectBase public class MeadeTelescopeBase : ReferenceCountedObjectBase
{ {
static MeadeTelescopeBase()
{
ClassName = nameof(MeadeTelescopeBase);
}
public static string ClassName { get; protected set; }
/// <summary> /// <summary>
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
/// </summary> /// </summary>
@@ -46,16 +39,16 @@ namespace ASCOM.Meade.net
SharedResourcesWrapper = sharedResourcesWrapper; 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 ReadProfile(); // Read device configuration from the ASCOM Profile store
IsConnected = false; // Initialise connected to false IsConnected = false; // Initialise connected to false
LogMessage(ClassName, "Completed initialisation"); LogMessage(className, "Completed initialisation");
LogMessage(ClassName, $"Driver version: {DriverVersion}"); LogMessage(className, $"Driver version: {DriverVersion}");
} }
/// <summary> /// <summary>