I'm going to use the FileDB dll from CodePlex. I honestly don't know anything about this project, but it looks like it should make for a good example. It's written in C#, and I guess I'll also stumble through calling C# from F#. Should theoretically be an easy thing.
First:
> #r "FileDB.dll";;
--> Referenced '/Users/Matthew/Desktop/FileDB.dll' (file may be locked by F# Interactive process)
Okay, well that looks promising! By the way, I've got the REPL in the working directory with the FileDB.dll. Okay, so now let's see if I can get anything working. The internets tell me that open is the way to reference a .NET namespace in F#.
> open Numeria.IO;;
>
Okay... Well, that gave me no output. Let's see if I've got a class there someplace:
> FileDB;;
FileDB;;
^^^^^^
/Users/Matthew/Desktop/stdin(3,1): error FS0803: Invalid use of a type name and/or object constructor. If necessary use 'new' and apply the constructor to its arguments, e.g. 'new Type(args)'. The required signature is:
FileDB(fileName: string, fileAccess: System.IO.FileAccess) : unit.
Whoa, interesting. So obviously there's something backing FileDB or I think I would get an error like this:
> BlahDB;;
BlahDB
^^^^^^
/Users/Matthew/Desktop/stdin(4,1): error FS0039: The value or constructor 'BlahDB' is not defined
So that's good! Let's try to create an empty db file. The FileDB documentation tells me that you would do this like so in C#:
No comments:
Post a Comment