admin管理员组文章数量:1323730
In a C# class I have the following definition
public event Action<Unit> Output1;
This type of definition is required by a third party application (TPA). This application imports a DLL containing classes with definitions like the above and expose these fields graphically.
I'd like to define these classes in F#. So I have tried the official equivalent
let output1 = Event<Unit>()
[<CLIEvent>]
member __.Output1 = output1.Publish
but the TPA application does not recognize it. I guess TPA is using reflection, so I inspected the C# and F# built DLL in ILSpy
public event Action<Unit> Output1;
[CLIEvent]
public event FSharpHandler<Unit> Output1
{
add
{
if (init@16 < 1)
{
LanguagePrimitives.IntrinsicFunctions.FailInit();
}
output1.Publish.AddHandler(value);
}
remove
{
if (init@16 < 1)
{
LanguagePrimitives.IntrinsicFunctions.FailInit();
}
output1.Publish.RemoveHandler(value);
}
}
So the reason why TPA does not recognize the F# definition is this difference. Hence my question:
Is there a way to define the member in F# so that it is built EXACTLY like the C# one?
本文标签: Defining C events in FStack Overflow
版权声明:本文标题:Defining C# events in F# - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742122040a2421758.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论