.net - How do define an event in F# visible from C# -
looking @ various bits of documentation, way of defining event in f#
class="lang-ml prettyprint-override">type xyz () = allow e = new event<t> fellow member x.something_happened : ievent<t> = x.publish unfortunately, type of ievent miscrosoft.fsharp.control.ievent<_>, , hence hard utilize within c#. articles suggest adding clievent attribute fellow member something_happended above seems create no difference far usability c# without including f# library goes.
how correctly define event in f# can add together delegate in c# code? many thanks.
there 2 event types in f#, event<'t> , event<'delegate, 'args>. sec 1 compiled .net event when [<clievent>] present. here's working example:
type t() = allow e = event<eventhandler<_>,_>() [<clievent>] fellow member x.myevent = e.publish fellow member x.raisemyevent() = e.trigger(x, eventargs.empty) in cases compiler generates warning if [<clievent>] used non-standard event type. i'm not sure why doesn't raise warning code (perhaps bug?).
c# .net f#
No comments:
Post a Comment