Is there a way to wrap multiple event declarations in a single [<CLIEvent>] block?

It's a little tedious to write:

let e1 = Event<_>()
let e... = Event<_>()
let en = Event<_>()

[<CLIEvent>]
member this.E1 = e1.Publish
[<CLIEvent>]
member this.E... = e....Publish
[<CLIEvent>]
member this.En = en.Publish

      

In the code, I'll show you how I need to write n

[<CLIEvent>]

, 1 for each event.

+3


source to share


1 answer


[<CLIEvent>]

is not a "block", it is an attribute.

The attribute is applied to the member immediately after it, so no, you cannot have the same attribute [<CLIEvent>]

applied to multiple members.



But you can put them on one line if that helps:

[<CLIEvent>] member this.E1 = e1.Publish
[<CLIEvent>] member this.E... = e....Publish
[<CLIEvent>] member this.En = en.Publish

      

+3


source







All Articles