Visual Studio 2010 and .NET 4 will include support for a new language called F#. I must admit that you have to learn how to love F#, it’s not that often love at first sight, because you just can’t figure out what is going on. Even though I’m beginning to like F# more and more and who knows… I might even love it some time soon. Today I got the time to think a lot, during a drive to and from a customer of mine, about how it should be to implement my minimal WCF 4 Service using F#, and it turned out to be pretty straight forward. I think I’ll be trying to use more of F# later on.
Notice how I decided to use the F# function printfn to output text to the console instead of Console.WriteLine which I could have used if I’d liked to.
1: open System
2: open System.ServiceModel
3: open System.ServiceModel.Description
6: type TimeService() =
8: member this.GetTime() =
11: let main =
12: use host = new ServiceHost(typeof<TimeService>, new Uri("http://localhost:4711"))
13: host.Description.Behaviors.Add(new ServiceMetadataBehavior(HttpGetEnabled = true));
16: printfn "Service is up'n running at %s" (host.Description.Endpoints..Address.ToString())
17: printfn "Press any key to shut down service"
All postings on this weblog, including code, scripts, labs and demos are provided "AS IS" with no warranties, and confer no rights. This weblog does not represent the thoughts, intentions, plans or strategies of Microsoft. It is solely my opinion. Because a weblog is intended to provide a semi-permanent point-in-time snapshot, you should not consider out of date posts to reflect current thoughts and opinions.