Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions FSharpScriptEngine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ type FSharpEngine(host: IScriptHost) =
let commonOptions = [| "c:\\fsi.exe"; "--nologo"; "--readline-"; "--noninteractive"|]
let session = FsiEvaluationSession.Create(fsiConfig, commonOptions, stdin, stdout, stderr)

do
session.EvalInteraction("let env = new System.Collections.Generic.Dictionary<string, obj>()")
let result = session.EvalExpression("System.Action<string, obj>(fun k v -> env.Add(k, v))")
match result with
| Some value -> let func : Action<string, obj> = unbox value.ReflectionValue in func.Invoke("Host", box host)
| None -> failwith "The system is down"

let (>>=) (d1:#IDisposable) (d2:#IDisposable) =
{ new IDisposable with
member x.Dispose() =
Expand Down
25 changes: 25 additions & 0 deletions scripts/test.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(*
let x = 1
let y = 2
x + y
|> printfn "%i"

let fizzbuzz n =
let rec loop acc n =
if n <= 0 then acc else
let result =
match n % 3, n % 5 with
| 0, 0 -> "FizzBuzz"
| 0, _ -> "Fizz"
| _, 0 -> "Buzz"
| _, _ -> string n
loop (result::acc) (n - 1)
loop [] n

fizzbuzz 10
|> List.iter (printfn "%s")
*)

let host : ScriptCs.Contracts.IScriptHost = unbox env.["Host"]
let adder = host.Require<Adder>()
adder.Add(3, 4) |> printfn "%i"