Sometimes ago I decided than I don’t need to inherit from Gadgeteer.Program class for my application’s entry point so I had replaced it with my own realization.
But the topic is not about that. Actually it about some strange thing that still not very clear for me.
Lets open a source codes of Gadgeteer.Program class.
This class have a following property:
protected internal static Mainboard Mainboard
{
get
{
if (_Mainboard == null) throw new Exception("Program instance must be constructed before Mainboard or any module is used (use a template)");
return _Mainboard;
}
protected set
{
if (_Mainboard != null) throw new Exception("Mainboard cannot be initialised twice");
Module.Mainboard = _Mainboard = value;
Debug.Print("Using mainboard " + Mainboard.MainboardName + " version " + Mainboard.MainboardVersion);
}
}
Take a look at line
Static property Module.Mainboard initialized with value.
But Module.Mainboard property is declared as protected!
```cs
public abstract partial class Module
{
/// <summary>
/// Gets a reference to the Mainboard API used by the current Gadgeteer Program.
/// </summary>
protected internal static Mainboard Mainboard;
}
So how it is possible to set protected property from another class?