-
Notifications
You must be signed in to change notification settings - Fork 67
/
Util.fs
29 lines (22 loc) · 1.05 KB
/
Util.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace ImpromptuInterface
module FSharpUtil=
open ImpromptuInterface
open System.Dynamic
///Wrap object to call the c# equivalent += dynamically when using f# dynamic set operator
type PropertySetCallsAddAssign(target:obj)=
inherit DynamicObject()
override this.TrySetMember(binder:SetMemberBinder, value:obj) =
Impromptu.InvokeAddAssign(target,binder.Name,value)
true
///Wrap object to call the c# equivalent -= dynamically when using f# dynamic set operator
type PropertySetCallsSubtractAssign(target:obj)=
inherit DynamicObject()
override this.TrySetMember(binder:SetMemberBinder, value:obj) =
Impromptu.InvokeSubtractAssign(target,binder.Name,value)
true
///Wrap object to use get operator to attach argument name for dynamic invocation
type PropertyGetCallsNamedArgument(target:obj)=
inherit DynamicObject()
override this.TryGetMember(binder:GetMemberBinder, result: obj byref) =
result <- InvokeArg(binder.Name,target)
true