Question about Aspects

Question 1: is it possible to add conditional compilation?
Question 2: is it possible to add a delegate?

The code I want to generate is:

Private Const LPC_SetWindowCaption = "setwindowcaption"
#if WEBASSEMBLY then
  Public Sub SetWindowCaptionDelegate(caption as String)
      Dim args As new RemObjects.Elements.RTL.Dictionary(Of String, String)
      args.add("caption", caption)
      LPC_Call.invoke(LPC_SetWindowCaption, args)
  End Sub
#else
  Public Delegate Sub SetWindowCaptionDelegate(caption as String)
  Public SetWindowCaption as SetWindowCaptionDelegate

  Public Sub SetWindowCaption_Dispatch(func As String, args As RemObjects.Elements.RTL.Dictionary(Of String, String), ByRef result As String) Handles Me.Dispatch
      If func = LPC_SetWindowCaption Then
        SetWindowCaption.Invoke(args("caption"))
        result = LPC_Ok
      End If
  End Sub
#end if

Cant you just check the target platform and emkitn just the right code? given that it shoukld be well-known at the time the aspect runs?

need to leave that for @ck.

1 Like

You can check conditionals via the services parameter. As for delegates, yes. Also via services.CreateDelegate.

2 Likes

I look in to it; did not find CreateDelegate yet.
Thanks.