Classes
Principle
Schematic
Top Level Class
// Class Scheme
[ITR registrar]
mdl::_ntfx_srv->create_proto((mpdl3*) => {
int *rfClassIns = mpdl3->ntfx_core(0, "classregistrar", true);
power});Last updated
// Class Scheme
[ITR registrar]
mdl::_ntfx_srv->create_proto((mpdl3*) => {
int *rfClassIns = mpdl3->ntfx_core(0, "classregistrar", true);
power});Last updated
using NTFX.Api;
namespace MyApp {
[NTFXPublic]
[NTFXTopLevel]
public class MyCustomApp : IClassModelDiscrete
{
public string Name => "MyCustomApp";
public string FullName => "MyCustomApp";
public string Description => "Does stuff";
public string Version => new Version("1.0.0");
public List<IApplication> Applications { get; set; } = new()
{
new MyCustomAppInfo()
};
public List<IClass> Classes { get; set; } = null;
public static async Task<IClassRoute> GetBasicRoute(AppContext _context)
{
return new ClassRootTree()
{
{"MyCustomAppInfo", typeof(MyCustomAppInfo)}
};
}
}
[NTFXPublic]
public class MyCustomAppInfo : IApplicationModelStandard
{
public static async Task<IApplicationOutput> Execute(AppContext _context)
{
if (_context.SystemRunner.ZeroOp.InstructionOrigin === "host")
{
// Check if system runner has a zero op.
_context.IO.WriteFormatted("SystemRunner Info");
_context.IO.WriteFormatted("\repeat{=}{12}");
// Prints: "============"
_context.IO.WriteFormatted("Enabled: \green{true}");
// Prints: "Enabled: true"
// NTFX requires apps to exit rather than just return
return _context.ReturnVoid();
}
// Request NTFX to let this app run in the background
if (await _context.RequestBackgroundAccess())
{
_context.SetBackgroundThread(async (_ctx) => {
// This runs in the background
// The new context does not have write features and stuff
await _ctx.Wait(3000);
let res = await _ctx.RequestImmediateAttention();
if (res.Success)
{
// Our current app is now focused
res.context.WriteFormatted("Writing from a background app");
return res.context.Return(("My", "Sample", "Object"));
}
else
{
return _ctx.ReturnVoid();
}
});
return _context.ReturnStaleOutput();
}
return _context.ReturnVoid();
}
}
}