F# Dynamic Operator using the DLR (Portable Class Library WinRT, .NET 4.5, Silverlight 5) + .NET 4.0 Library
Install from nuget
PM> Install-Package FSharp.Dynamic
target?Property
, target?Property<-value
, and target?Method(arg,arg2)
allow you to dynamically get/set properties and call methods
Also >?>
(dynImplicit
), >>?>>
(dynExplicit
) and more.
###System.Dynamic open FSharp.Dynamic let ex1 = ExpandoObject() ex1?Test<-"Hi"//Set Dynamic Property ex1?Test //Get Dynamic
###SignalR
open FSharp.Dynamic
type MyHub =
inherit Hub
member x.Send (name : string) (message : string) =
base.Clients.All?addMessage(name,message) |> ignore
###MVC ViewBag
x.ViewBag?Name<-"George"
#Caveats:
The dlr
is incompatible with interface explicit members, so are these operators, just like C#'s dynamic
keyword.
The default maintainer account for projects under "fsprojects" is @fsgit - F# Community Project Incubation Space (repo management)