Previously I only used an interface ISensor.cs and implemented it completely in each script I wrote but I wanted to clean things up and reduce script size so I created a base SensorBase.cs which uses ISensor.cs, both of which are contained in the PC2MQTT.Sensors namespace.
namespace PC2MQTT.Sensors
{
public partial class SensorBase : ISensor
{
// A very bad logging library. BadLogger is the namespace.
internal BadLogger.BadLogger Log;
}
}
Here is the script I load with cs-script. There is more in the file, but the Log object is what I need to access from the SensorBase.cs class. I will override any methods I do not want the default implementation of here from SensorBase.
Example.cs script loaded by cs-script code above:
public class Example : SensorBase, ISensor
{
// error CS0103: The name 'Log' does not exist in the current context
}
But in the Example script it is not able to find the Log object from SensorBase.cs. Is there a way for me to reference Log object from SensorBase.cs in my scripts?
Previously I only used an interface
ISensor.cs
and implemented it completely in each script I wrote but I wanted to clean things up and reduce script size so I created a baseSensorBase.cs
which usesISensor.cs
, both of which are contained in thePC2MQTT.Sensors
namespace.Somewhere I call:
SensorBase.cs:
Here is the script I load with cs-script. There is more in the file, but the Log object is what I need to access from the
SensorBase.cs
class. I will override any methods I do not want the default implementation of here fromSensorBase
.Example.cs
script loaded by cs-script code above:But in the Example script it is not able to find the Log object from
SensorBase.cs
. Is there a way for me to referenceLog
object fromSensorBase.cs
in my scripts?