写作有点乏味:
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
在代码中,我展示了如何为每个事件编写n
[<CLIEvent>]
,1。
答案 0 :(得分:3)
[<CLIEvent>]
不是“块”,它是属性。
属性会立即应用于成员,因此,您不能将相同的[<CLIEvent>]
属性应用于多个成员。
但如果有帮助,你可以把它们放在同一条线上:
[<CLIEvent>] member this.E1 = e1.Publish
[<CLIEvent>] member this.E... = e....Publish
[<CLIEvent>] member this.En = en.Publish