<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>codesling</title>
        <link>http://geekswithblogs.net/Erik/Default.aspx</link>
        <description>[FP, cores] |&gt; future</description>
        <language>en-US</language>
        <copyright>Erik Araojo</copyright>
        <managingEditor>erik_araojo@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>codesling</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/Erik/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>If you let your friends touch your private parts</title>
            <link>http://geekswithblogs.net/Erik/archive/2010/09/20/141897.aspx</link>
            <description>&lt;p&gt;you must be a C++ programmer.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: xx-small"&gt;&lt;span style="font-family: Comic Sans MS"&gt;{Seen at stackoverflow: &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: xx-small"&gt;&lt;a href="http://stackoverflow.com/questions/2349378?page=3&amp;amp;tab=votes#tab-top"&gt;&lt;span style="font-family: Comic Sans MS"&gt;http://stackoverflow.com/questions/2349378?page=3&amp;amp;tab=votes#tab-top&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: xx-small"&gt;&lt;span style="font-family: Comic Sans MS"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: xx-small"&gt; &lt;/span&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/141897.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2010/09/20/141897.aspx</guid>
            <pubDate>Mon, 20 Sep 2010 05:29:57 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/141897.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2010/09/20/141897.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/141897.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/141897.aspx</trackback:ping>
        </item>
        <item>
            <title>Dynamically Hosting WCF Services using WcfStormHost</title>
            <link>http://geekswithblogs.net/Erik/archive/2010/08/04/141185.aspx</link>
            <description>&lt;p&gt;One of the benefits of using WCF is that you're not  required to host it in IIS.  Most people create console hosts during development and then just use windows service in production.  This is a quick and very easy way of hosting WCF services especially if you just have 2 or 3 services.  However, when the number of wcf services gets too high, controlling them using the mmc snap-in (services.msc) can get a bit tedious (maybe not if your powershell or WMI kung fu skills are quite good). &lt;/p&gt;
&lt;p&gt;However, if you're tired of writing these repetetive console/windows service hosts and is looking for another way of managing WCF services, then try out WcfStormHost.  It will let you dynamically host WCF Services without ever writing a single code.  Each WCF service is hosted in its own AppDomain so you wont have to worry about wcf services interfering with each other.&lt;br /&gt;
&lt;br /&gt;
Here's a quick rundown of its features&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;&lt;strong&gt;Auto-discover and host WCF services&lt;/strong&gt;&lt;br /&gt;
    - WcfStormHost can read a folder containing assemblies (*.dll and *.exe) and *.config and automatically determine the service type to host.&lt;br /&gt;
    &lt;br /&gt;
    &lt;a target="_blank" href="http://www.wcfstorm.com/wcf/Data/Sites/1/WcfStormHost/wcfstormHost-Main.png"&gt;&lt;img alt="" width="200" height="245" src="http://www.wcfstorm.com/wcf/Data/Sites/1/WcfStormHost/wcfstormHost-Main.png" /&gt;&lt;/a&gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;a target="_blank" href="http://www.wcfstorm.com/wcf/Data/Sites/1/WcfStormHost/SelectWcfServiceToLoad.PNG"&gt;&lt;img alt="" width="200" height="136" src="http://www.wcfstorm.com/wcf/Data/Sites/1/WcfStormHost/SelectWcfServiceToLoad.PNG" /&gt;&lt;/a&gt;&lt;br /&gt;
     &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;It monitors changes in the *.dll and *.config files&lt;/strong&gt;.  If it detects changes, it automatically re-hosts the service!  You won't have to manually restart the service, unlike a windows service host. It doesnt lock the assembly file which means deployment is much simplified.  You just simple need to copy over the dll or config file.&lt;br /&gt;
    &lt;br /&gt;
    During development this is also very useful  because you can setup WcfStormHost to host a service located in your &lt;em&gt;$Project/bin/Debug &lt;/em&gt;folder.  This means that everytime you make a code change and recompile, the service automatically gets re-hosted.&lt;br /&gt;
     &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;It has a simple, intuitive UI for managing services.   &lt;/strong&gt;WcfStormHost  (specifically the system tray host) can be started as an application that sits on your system stray (as in the screenshot above) which means it is easy to find.  If you need to do something on a wcf service, just click on the system tray icon and the main UI will popup over it.&lt;br /&gt;
     &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;It can auto-load wcf services.  &lt;/strong&gt;WcfStormHost has an optional config file called&lt;em&gt; Host.config&lt;/em&gt;.  This file can be created by clicking the "&lt;em&gt;Save&lt;/em&gt;" icon in the menu.  The host.config file can contain a list of WCF services which are automatically loaded at startup.  Shown below is a sample service configured to be auto-started.  The assembly files + the config file (&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: #a31515"&gt;ConfigFile&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;WcfService.dll.config&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ConfigFile&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;) are located in the value specified by the &lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: #a31515"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; &lt;/span&gt;node.&lt;br /&gt;
    &lt;br /&gt;
    &lt;pre style="font-family: consolas"&gt;&lt;span style="color: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WcfService&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;MySvc&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;WcfService.MyTestSvc, WcfService&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Status&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Start&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Status&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;BinFolder&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;          &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ConfigFile&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;WcfService.dll.config&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ConfigFile&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;          &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;D:\Work\Source-Mine\WcfStormHost\WcfService\bin\Debug&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;BinFolder&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Activity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;          &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ShutDownifIdle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ShutDownifIdle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;          &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxIdleTime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;10000&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxIdleTime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Activity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WcfService&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;For quick debugging, it allows you to trace WCF messages being sent and received by the hosted wcf service&lt;/strong&gt;.  Just select a service and then click on the "Trace" button on the right-hand side.  Shown below is the trace window.&lt;br /&gt;
    &lt;br /&gt;
    &lt;a target="_blank" href="http://www.wcfstorm.com/wcf/Data/Sites/1/WcfStormHost/WcfStormHostTrace.PNG"&gt;&lt;img alt="" width="200" height="150" src="http://www.wcfstorm.com/wcf/Data/Sites/1/WcfStormHost/WcfStormHostTrace.PNG" /&gt;&lt;/a&gt;&lt;br /&gt;
     &lt;/li&gt;
    &lt;li&gt;It creates log files for each of the hosted services.  The log files are created daily and can be configured not to exceed a certain size.  By default a log file can not exceed 0.5 MB.  Old log files and log files that exceed the size limit are moved into the "archive" folder.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;      Try it out and see for yourself. &lt;a href="http://www.wcfstorm.com/wcf/getting-started-with-wcfstormhost.aspx"&gt;Get Started&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;       &lt;a href="http://www.wcfstorm.com"&gt;Download WcfStormHost &lt;/a&gt;(&lt;strong&gt;&lt;span style="background-color: #3366ff"&gt;blue &lt;/span&gt;&lt;/strong&gt;download icon on the right hand-side)&lt;/p&gt;
&lt;p&gt;These are the current features of WcfStormHost and of course suggestions for more features are most welcome!  Please post it in the comments or send a mail to &lt;a href="mailto:erik-dot-araojo@wcfstorm.com"&gt;erik-dot-araojo@wcfstorm.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;   &lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/141185.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2010/08/04/141185.aspx</guid>
            <pubDate>Wed, 04 Aug 2010 12:36:13 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/141185.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2010/08/04/141185.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/141185.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/141185.aspx</trackback:ping>
        </item>
        <item>
            <title>Composite Design Pattern in F#</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/12/04/136688.aspx</link>
            <description>&lt;p&gt;One of the more common design patterns used in object oriented languages like C# is the &lt;a href="http://en.wikipedia.org/wiki/Composite_pattern"&gt;Composite Pattern&lt;/a&gt;.   The main benefit of using this pattern is that it allows us to treat individual objects and composite of objects in the same way.  In the UML below, the type &lt;strong&gt;Component &lt;/strong&gt;is abstract and defines the operations (method1 and method2) which are implemented by the concrete types &lt;strong&gt;Leaf and Composite&lt;/strong&gt;.  The type &lt;strong&gt;Composite &lt;/strong&gt;contains a collection of Component objects.  Due to the fact that it inherits from &lt;em&gt;Component &lt;/em&gt;we can write code that invokes method1 and method2 without knowing the specific type.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Composite Pattern UML" src="http://www.techscore.com/tech/DesignPattern/img/composite3.gif" /&gt;&lt;/p&gt;
&lt;p&gt;For example, suppose we work at a fast food chain and we'd like to write code for computing the price of  fries, burger, coke or a combo meal.  Following the composite pattern, we could create an abstract class called &lt;em&gt;Product &lt;/em&gt;which has the GetPrice() method and then one class each for Burger, Fries, Coke and ComboMeal.&lt;/p&gt;
&lt;p&gt;Component  ---  maps to   --&amp;gt;  Product&lt;br /&gt;
Leaf                --- maps to    --&amp;gt;  Burger, Fries, Coke&lt;br /&gt;
Composite   --- maps to    ---&amp;gt; ComboMeal&lt;br /&gt;
&lt;br /&gt;
Our C# code would look like&lt;/p&gt;
&lt;p&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;abstract&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;    {&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;abstract&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; GetPrice();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Fries&lt;/span&gt;&lt;span style="color: #000000"&gt; : &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;    {&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;override&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; GetPrice()&lt;br /&gt;
        {&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; 1.0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Burger&lt;/span&gt;&lt;span style="color: #000000"&gt; : &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;    {&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;override&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; GetPrice()&lt;br /&gt;
        {&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; 5.0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Coke&lt;/span&gt;&lt;span style="color: #000000"&gt; : &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;    {&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;override&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; GetPrice()&lt;br /&gt;
        {&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; 2.0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ComboMeal&lt;/span&gt;&lt;span style="color: #000000"&gt; : &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;    {&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;gt; _products = &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;gt;();&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt;&lt;span style="color: #000000"&gt; Add(&lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;/span&gt;&lt;span style="color: #000000"&gt; p)&lt;br /&gt;
        {&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;&lt;span style="color: #000000"&gt;._products.Add(p);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;override&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; GetPrice()&lt;br /&gt;
        {&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt;&lt;span style="color: #000000"&gt; sum = 0.0;&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;&lt;span style="color: #000000"&gt; (&lt;/span&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt;&lt;span style="color: #000000"&gt; p &lt;/span&gt;&lt;span style="color: #0000ff"&gt;in&lt;/span&gt;&lt;span style="color: #000000"&gt; _products)&lt;br /&gt;
                sum += p.GetPrice();&lt;br /&gt;
&lt;br /&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; sum;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;we can then write a helper method that Computes a price. This method does not need to know whether its computing the price of a single item (Fries, Burger ) or that of a combo meal.&lt;/p&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;static&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; ComputePrice(&lt;/span&gt;&lt;span style="color: #2b91af"&gt;Product&lt;/span&gt;&lt;span style="color: #000000"&gt; p)&lt;br /&gt;
 {&lt;/span&gt;&lt;span style="color: #000000"&gt;&lt;br /&gt;
       return p.GetPrice();&lt;br /&gt;
 }&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
Suppose, someone ordered 1 fries and 1 Burger separately, our code will be,&lt;/p&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt; &lt;span style="color: #0000ff"&gt;var&lt;/span&gt;&lt;span style="color: #000000"&gt; totalFriesAndBurger = ComputePrice(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Fries&lt;/span&gt;&lt;span style="color: #000000"&gt;()) + ComputePrice(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Burger&lt;/span&gt;&lt;span style="color: #000000"&gt;());&lt;br /&gt;
          &lt;/span&gt;&lt;span style="color: #000000"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt; Now if another one ordered a Combo meal (Fries + Coke + Burger), our code will be&lt;/p&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt;&lt;span style="color: #000000"&gt; combo = &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ComboMeal&lt;/span&gt;&lt;span style="color: #000000"&gt;();&lt;br /&gt;
combo.Add(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Fries&lt;/span&gt;&lt;span style="color: #000000"&gt;());&lt;br /&gt;
combo.Add(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Burger&lt;/span&gt;&lt;span style="color: #000000"&gt;());&lt;br /&gt;
combo.Add(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Coke&lt;/span&gt;&lt;span style="color: #000000"&gt;());&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt;&lt;span style="color: #000000"&gt; totalCombo = ComputePrice(combo);&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt; That's it. &lt;/p&gt;
&lt;p&gt;For our C# implementation (not counting the helper method ComputePrice() ), we &lt;strong&gt;have 5 classes and approximately 40 lines of code.&lt;/strong&gt;&lt;/p&gt;
&lt;h4&gt; &lt;/h4&gt;
&lt;h4&gt;Now lets see how we can implement the same pattern in F#.&lt;/h4&gt;
&lt;p&gt;Knowing that  the types &lt;em&gt;Fries, Burger, Coke and ComboMeal&lt;/em&gt; are just different representations of the &lt;em&gt;Product &lt;/em&gt;type, we can model this relationship cleanly in F# using &lt;strong&gt;discriminated unions&lt;/strong&gt;.   To represent the the combo meal, we make it into a tupleof 2 products.  An item of this tuple can be a single product (Coke, Fries or Burger) or any combination (i.e a combo)&lt;/p&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt;type&lt;/span&gt;&lt;span style="color: #000000"&gt; Product =&lt;br /&gt;
| Fries &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; double&lt;br /&gt;
| Coke &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; double &lt;br /&gt;
| Burger &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; double&lt;br /&gt;
| Combo &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; Product * Product&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt; And how about the GetPrice method, you'd ask?  That's easy enough; F# allows us to add methods to union types. Implementing that, our code now looks like this. Notice the "&lt;span style="color: #0000ff"&gt;with member w.GetPrice()"&lt;/span&gt; part?&lt;/p&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt;type&lt;/span&gt;&lt;span style="color: #000000"&gt; Product =&lt;br /&gt;
| Fries &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; double&lt;br /&gt;
| Coke &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; double &lt;br /&gt;
| Burger &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; double&lt;br /&gt;
| Combo &lt;/span&gt;&lt;span style="color: #0000ff"&gt;of&lt;/span&gt;&lt;span style="color: #000000"&gt; Product * Product&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #0000ff"&gt;with&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;member&lt;/span&gt;&lt;span style="color: #000000"&gt; w.GetPrice() = &lt;br /&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;match&lt;/span&gt;&lt;span style="color: #000000"&gt; w &lt;/span&gt;&lt;span style="color: #0000ff"&gt;with&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;br /&gt;
    | Fries(p) | Coke(p) | Burger(p)&lt;/span&gt;&lt;span style="color: #0000ff"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt; p&lt;br /&gt;
    | Combo(p1,p2) &lt;/span&gt;&lt;span style="color: #0000ff"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt; p1.GetPrice() + p2.GetPrice()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;Again, if someone ordered a combo meal our code will look like&lt;/p&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt;let&lt;/span&gt;&lt;span style="color: #000000"&gt; combomeal = Combo(fries, Combo(burger, coke))&lt;br /&gt;
Console.WriteLine(&lt;/span&gt;&lt;span style="color: #800000"&gt;"Combo meal Total = "&lt;/span&gt;&lt;span style="color: #000000"&gt; + combomeal.GetPrice().ToString())&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt; That's just cool isn't it? &lt;strong&gt;With F# we ony 1 Union type and about 10 lines of code&lt;/strong&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/136688.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/12/04/136688.aspx</guid>
            <pubDate>Fri, 04 Dec 2009 10:27:10 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/136688.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/12/04/136688.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/136688.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/136688.aspx</trackback:ping>
        </item>
        <item>
            <title>Purchased "Functional Programming in the Real World" book :)</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/12/03/136670.aspx</link>
            <description>&lt;p&gt;I bought myself an early christmas gift and purchased the book "Functional Programming in the Real World" by &lt;a href="http://tomasp.net/blog/"&gt;Tomas Petricek&lt;/a&gt;.  The book is available through Manning's early access program.  I've been drooling over this book for a long time and finally I have it now!  (cue music: Jingle bells, jingle bells jingle all the way..)&lt;/p&gt;
&lt;p&gt;Sadly though I have an exam coming (I'm taking my masters in Software Engineering) in 2 weeks time and now I need to force myself to study the lecture notes and not read Tomas's book. Arrgh.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;P.S I was able to buy the book using donations from &lt;/em&gt;&lt;a href="http://storm.codeplex.com"&gt;&lt;em&gt;Storm&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. Thanks guys!&lt;/em&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/136670.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/12/03/136670.aspx</guid>
            <pubDate>Thu, 03 Dec 2009 06:33:06 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/136670.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/12/03/136670.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/136670.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/136670.aspx</trackback:ping>
        </item>
        <item>
            <title>WCFStorm version 1.1 is released</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/07/30/133826.aspx</link>
            <description>&lt;p&gt;A few months ago I've promised that version 1.1 will be released in July.  Today I make good on that promise and am happy to announce that version 1.1 is ready for download!&lt;/p&gt;
&lt;p&gt;A very big thanks goes out to those who not only have purchased WCFStorm but also provided valuable feedback in terms of feature requests and bug reports.  Thank you very much guys.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Below are the &lt;strong&gt;main features of version 1.1&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Loading of existing client App.config files into WCFStorm &lt;/li&gt;
    &lt;li&gt;One-click execution of all functional test cases under a method or of the whole WCF service. &lt;/li&gt;
    &lt;li&gt;A plugin interface for custom validations of functional test cases. &lt;/li&gt;
    &lt;li&gt;A plugin interface for randomizing requests or re-using the previous response as input to the next request. &lt;/li&gt;
    &lt;li&gt;A plugin interface for programmatically modifying the ServiceEndpoint instance &lt;/li&gt;
    &lt;li&gt;A plugin interface to support Duplex services &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here's the full list of &lt;a href="http://www.wcfstorm.com/wcf/whats-new-in-version-11.aspx"&gt;what's new in 1.1&lt;/a&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/133826.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/07/30/133826.aspx</guid>
            <pubDate>Fri, 31 Jul 2009 03:44:32 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/133826.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/07/30/133826.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/133826.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/133826.aspx</trackback:ping>
        </item>
        <item>
            <title>WCFStorn : How to create and execute a functional test case</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/04/07/130799.aspx</link>
            <description>If you're not yet familiar on how to add a service and invoke a method, please see &lt;font size="3"&gt; &lt;a href="../../../../Erik/archive/2009/04/04/130731.aspx"&gt;Getting Started&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/font&gt;The short video below shows how to create and execute a functional test case in WCFStorm.  Towards the end of the video, it shows one of the main features of functional testing with WCFStorm - which is the ability to visually view the difference between the expected and actual responses in a test.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;font size="3"&gt;&lt;/font&gt;&lt;embed src="http://www.youtube.com/v/SHpvL5DGSgU&amp;amp;hl=en&amp;amp;fs=1" width="425" height="344" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/130799.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/04/07/130799.aspx</guid>
            <pubDate>Wed, 08 Apr 2009 02:48:51 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/130799.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/04/07/130799.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/130799.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/130799.aspx</trackback:ping>
        </item>
        <item>
            <title>WCFStorm : How to create and run a performance test case</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/04/07/130793.aspx</link>
            <description>&lt;p&gt;If you're not yet familiar on how to add a service and invoke a method, please see  &lt;font style="FONT-WEIGHT: bold" size="3"&gt;&lt;a href="http://geekswithblogs.net/Erik/archive/2009/04/04/130731.aspx"&gt;Getting Started&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The video below shows the steps on how to create and run performance test cases.  When a performance test case is executed, WCFStorm captures the responses and displays a graph in real-time the actual and average response times as well the rate at which the service is responding the method invocations.&lt;/p&gt;
&lt;h3&gt;The following are the performance test parameters&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Number of agents&lt;/span&gt;
    &lt;ul&gt;
        &lt;li&gt;This is the number of background workers that will repeatedly invoke the service method until the test is stopped or the test duration has completed. &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Rampup &lt;/span&gt;
    &lt;ul&gt;
        &lt;li&gt;This is the interval in seconds at which the agents are created.  For example, if the rampup value is "1", every second, WCFStorm will create an agent until it has reached the specified number of agents&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Test duration&lt;/span&gt;
    &lt;ul&gt;
        &lt;li&gt;This is the test duration in seconds&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Invoke interval&lt;/span&gt;
    &lt;ul&gt;
        &lt;li&gt;This is the interval in &lt;span style="BACKGROUND-COLOR: rgb(255,255,153)"&gt;milliseconds &lt;/span&gt;at which an agent repeatedly invokes a service method&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sample Perf Test setup&lt;/strong&gt;&lt;/p&gt;
&lt;ol style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
    &lt;ol&gt;
        &lt;li&gt;Constant Load
        &lt;ul&gt;
            &lt;li&gt;This can be achieved by setting the "Rampup" value to &lt;font color="#800000"&gt;zero&lt;/font&gt;&lt;/li&gt;
        &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;Incrementing number of users
        &lt;ul&gt;
            &lt;li&gt;Set "Rampup" and "Number of Agents" to a non-zero value.&lt;/li&gt;
        &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ol&gt;
&lt;/ol&gt;
&lt;p dir="ltr"&gt; &lt;/p&gt;
&lt;strong&gt;&lt;/strong&gt;&lt;object width="425" height="344"&gt;
&lt;p&gt;&lt;embed height="344" type="application/x-shockwave-flash" width="425" src="http://www.youtube.com/v/PEO88hvXAew&amp;amp;color1=0xb1b1b1&amp;amp;color2=0xcfcfcf&amp;amp;hl=en&amp;amp;feature=player_embedded&amp;amp;fs=1" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/p&gt;
&lt;/object&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;Some screenshots&lt;/h3&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="639" height="386" src="/images/geekswithblogs_net/Erik/WcfStorm/WcfStormPerfTest2.jpg" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="634" height="384" src="/images/geekswithblogs_net/Erik/WcfStorm/WcfStormPerfTest.jpg" /&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/130793.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/04/07/130793.aspx</guid>
            <pubDate>Tue, 07 Apr 2009 21:52:50 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/130793.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/04/07/130793.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/130793.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/130793.aspx</trackback:ping>
        </item>
        <item>
            <title>WCFStorm : Testing a service having multiple bindings</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/04/04/130732.aspx</link>
            <description>&lt;p&gt;In order for &lt;a href="http://geekswithblogs.net/Erik/archive/2009/04/02/130664.aspx"&gt;WCFStorm&lt;/a&gt; to invoke a service having a netTcp endpoint, the service must be configured to expose the WSDL via http.  A sample config for the WCF service will be,&lt;/p&gt;
&lt;p&gt; &lt;img alt="" src="http://www.fileden.com/files/2009/4/1/2388287/MultipleBinding.Png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;In above configuration, the service is using 3 bindings.  mexHttpBindings is used to expose the WSDL, while netTcpBinding and wsHttpBinding are for the actual methods calls. To test the serivice using WCFStorm, use the mexHttpBinding url to add the service.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://www.fileden.com/files/2009/4/1/2388287/AddServiceEndpoint.Png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://www.fileden.com/files/2009/4/1/2388287/DiscoverMultipleLog.Png" /&gt;  &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;As  can be seen from the log, the tool detected both the netTcpBinding and WsHttpBindings.  If we select a method and invoke it ( (please see &lt;a href="http://geekswithblogs.net/Erik/archive/2009/04/04/130731.aspx"&gt;getting started&lt;/a&gt; on the steps to invoke a method) , the tool will select the endpoint that was declared first (which is NetTcpBinding).  If you'd like to use the other endoint, wsHttpBinding, right-click the service and select "ModifyEndpoint"  &lt;/p&gt;
&lt;p&gt;           &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://www.fileden.com/files/2009/4/1/2388287/modifyEndpoint.png" /&gt;&lt;/p&gt;
&lt;p&gt;     &lt;/p&gt;
&lt;p&gt; This will bring up a form which lets you choose the binding that you'd like to use.  Click on the dropdown to select a new binding.  You can also specify a new endpoint address in this form.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://www.fileden.com/files/2009/4/1/2388287/selectBinding.png" /&gt;  &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; Click OK to use the selected binding.  This will trigger WCFStorm to regenerate a proxy class that uses the new binding. All subsequent method invocations will now use the new proxy (and hence the new binding).&lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/130732.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/04/04/130732.aspx</guid>
            <pubDate>Sat, 04 Apr 2009 19:57:39 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/130732.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/04/04/130732.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/130732.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/130732.aspx</trackback:ping>
        </item>
        <item>
            <title>WCFStorm : How To's</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/04/04/130731.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;EDIT : Please visit &lt;/em&gt;&lt;a href="http://www.wcfstorm.com/wcf/learn-more.aspx"&gt;&lt;em&gt;www.wcfstorm.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt; for th updated tutorials.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This is a first in a series for post describing the tasks and the features available in&lt;a href="http://geekswithblogs.net/Erik/archive/2009/04/02/130664.aspx"&gt;WCF Storm&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt; 1. Getting Started&lt;/p&gt;
&lt;p&gt;2. &lt;a href="http://geekswithblogs.net/Erik/archive/2009/04/04/130732.aspx"&gt;Invoking a service having multiple endpoints.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;3. &lt;a href="http://geekswithblogs.net/Erik/archive/2009/04/07/130793.aspx"&gt;How to create and run a performance test&lt;/a&gt;&lt;/p&gt;
4. &lt;a href="javascript:void(0);/*1239114171625*/"&gt;How to create and execute a functional test&lt;/a&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;Ok, so lets get started....&lt;/p&gt;
&lt;h2&gt; Getting Started : (Invoking a method of  a WCF/Web service)&lt;/h2&gt;
&lt;ol&gt;
    &lt;li&gt;
    &lt;h3&gt;Add a service.&lt;/h3&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
&lt;p&gt;This can be done by either clicking "File --&amp;gt; Service --&amp;gt; Add" or by clicking the Add button in the menu bar.&lt;/p&gt;
&lt;p&gt;This will bring up a form where you can type in the metadata exchange endpoint (i.e. WSDL endpoint). WcfStorm will then read the wsdl, generate the client code and compile it. If all goes well, the service and its method will be displayed on the left hand side.&lt;/p&gt;
&lt;p&gt; &lt;img alt="" width="654" height="175" src="/images/geekswithblogs_net/Erik/WcfStorm/AddServiceEndpoint(1).Png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;  Now go ahead and select on method&lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;h3&gt;           2.  Select a method&lt;/h3&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
&lt;p&gt; If a method is selected, its parameters will be read and displayed in the "RequestPane'.  In the screenshot below I've selected the method "GetDataUsingContract" which takes parameter of type "CompositeType"&lt;/p&gt;
&lt;p&gt; &lt;img alt="" width="635" height="283" src="/images/geekswithblogs_net/Erik/WcfStorm/MethodSelected.Png" /&gt;&lt;/p&gt;
&lt;p&gt; The structure of CompositeType is shown below.  As you can see, what's displayed in the request pane matches exactly the defined type. &lt;/p&gt;
&lt;p&gt; &lt;img alt="" width="311" height="396" src="/images/geekswithblogs_net/Erik/WcfStorm/CompositeTypeClass.Png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Now, select a field of the composite type parameter.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;h3&gt;            3.  Edit a field in the parameter&lt;/h3&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
&lt;p&gt; This will bring up the Object Editor which will let you edit the field.  If the type is not primitive, the "Set to null' checkbox will be enabled.  If the tye of the selected field is polymorphic, the object editor will display the subtypes that can be assigned to the field.&lt;/p&gt;
&lt;p&gt; Here I've selected the string field.&lt;/p&gt;
&lt;p&gt; &lt;img alt="" width="386" height="292" src="/images/geekswithblogs_net/Erik/WcfStorm/EditObject(1).Png" /&gt;&lt;/p&gt;
&lt;p&gt;  Clicking OK will assign the value "my string" to the StringValue field of the CompositeType parameter.&lt;/p&gt;
&lt;p&gt; Now Click Send (Green arrow)&lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;h3&gt;          4.  Invoking the service method&lt;/h3&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
&lt;p&gt; Click on send to invoke the web method.   The test service we are invoking merely echoes back the input parameters it has received ( a convenient way of checking that the object editor in the previous step worked). This is shown in the screenshot below&lt;/p&gt;
&lt;p&gt; &lt;img alt="" src="http://www.fileden.com/files/2009/4/1/2388287/InvokeMethodWithResult.Png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Looking at the log, we can see that WCFStorm used the &lt;strong&gt;NetTcpBinding&lt;/strong&gt; endpoint.  Recall that when we added the service, we used &lt;a href="http://localhost:8080/httpEndpoint?wsdl"&gt;http://localhost:8080/httpEndpoint?wsdl&lt;/a&gt; - obvoiusly an endpoint that uses http. So how come the tool is now using NetTcpBinding?  In this case, the service that we are using declared 3 endpoints in its config.  An http endpoint for the metadata exchange (to expose the wsdl)  a NetTcpBinding and a WsHttpBinding endpoint for the actual method calls.  By default WCFStorm uses 1st endpoint that was declared by the service (which was the NetTcpBinding.)&lt;/p&gt;
&lt;p&gt; &lt;img alt="" width="753" height="331" src="/images/geekswithblogs_net/Erik/WcfStorm/MultipleBinding.Png" /&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;         That's it! we have now successfully invoked the WCF service.&lt;/p&gt;
&lt;ol&gt;  &lt;/ol&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/130731.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/04/04/130731.aspx</guid>
            <pubDate>Sat, 04 Apr 2009 19:19:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/130731.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/04/04/130731.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/130731.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/130731.aspx</trackback:ping>
        </item>
        <item>
            <title>WCF Service Functional and Performance Testing Tool : WCFStorm</title>
            <link>http://geekswithblogs.net/Erik/archive/2009/04/02/130664.aspx</link>
            <description>&lt;p&gt;During the last few months I've been working on a commercial tool for testing WCF services.  The knowledge I learned building &lt;a href="http://codeplex.com/storm"&gt;STORM&lt;/a&gt; really helped alot in building this tool.  So here it is my fellow coders,&lt;strong&gt; WCF Storm&lt;/strong&gt;.  It has more features than its open source cousin, STORM and the best part is &lt;strong&gt;&lt;font color="#339966"&gt;it works on both WCF and Web services&lt;/font&gt;&lt;/strong&gt;&lt;font color="#339966"&gt;!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#339966"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#339966"&gt;&lt;font size="3"&gt;&lt;em&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#339966"&gt;&lt;font size="3"&gt;&lt;em&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#339966"&gt;&lt;font size="3"&gt;&lt;em&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#339966"&gt;&lt;font size="3"&gt;&lt;em&gt;&lt;font color="#000000"&gt;EDIT :&lt;/font&gt; &lt;/em&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;em&gt;&lt;a href="http://www.wcfstorm.com/wcf/home.aspx"&gt;www.wcfstorm.com&lt;/a&gt;&lt;/em&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;em&gt; &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="3"&gt;&lt;em&gt;is up! Please visit the site for updates and to purchase WCFStorm online&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;
&lt;h3&gt; &lt;/h3&gt;
&lt;h3&gt;System Requirement:&lt;/h3&gt;
&lt;ul style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
    &lt;ul&gt;
        &lt;li&gt; .NET Framework 3.0 or higher. &lt;/li&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;h3&gt; Features at a glance:&lt;/h3&gt;
&lt;p&gt;         &lt;strong&gt;General:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;ul&gt;
        &lt;li&gt;Dynamically invoke and test WCF Services &lt;/li&gt;
        &lt;li&gt;Dynamically invoke and test Web services written in any language &lt;/li&gt;
        &lt;li&gt;Save your opened service and its test cases into a "project" which can be reloaded anytime &lt;/li&gt;
        &lt;li&gt;Dynamically invoke service methods even those containing complex data types &lt;/li&gt;
        &lt;li&gt;UI-based, dynamic editing of complex data types &lt;/li&gt;
        &lt;li&gt;Test multiple WCF and Web services within a single UI. &lt;/li&gt;
        &lt;li&gt;Multiple-tabbed interface &lt;/li&gt;
        &lt;li&gt;Basic and windows authentication &lt;/li&gt;
        &lt;li&gt;Test services sitting behind a proxy &lt;/li&gt;
        &lt;li&gt;Dynamically modify the URL endpoint of a WCF or Web service. &lt;/li&gt;
        &lt;li&gt;Dynamically edit the service binding. &lt;/li&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;         &lt;strong&gt;Functional Testing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;ul&gt;
        &lt;li&gt;Create functional test cases and save it as part of a project &lt;/li&gt;
        &lt;li&gt;Create and save functional test cases containing Expected results. &lt;/li&gt;
        &lt;li&gt;Graphically compare (side-by-side) the expected results with the actual response of a service. &lt;/li&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;          &lt;strong&gt;Performance Testing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;ul&gt;
        &lt;li&gt;Create performance test cases and save it as part of a project &lt;/li&gt;
        &lt;li&gt;Graphically display charts in real-time as the performance test progresses. &lt;/li&gt;
        &lt;li&gt;Configurable test parameters (# of Agents, Test duration, interval etc.).  You can stress out your service as much as you want. &lt;/li&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;          What all these features mean is that testing WCF/Web services becomes a breeze and you'll have plenty of time to spend on writing the logic of your service (which is what you should be really doing).&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;  &lt;u&gt;Performance testing screenshot:&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;                &lt;img alt="WCF Storm Performance Testing" width="634" height="384" src="/images/geekswithblogs_net/Erik/WcfStorm/WcfStormPerfTest.jpg" /&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;              &lt;u&gt;Functional testing screenshot:&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;               &lt;img alt="WCF Storm Functional Testing" width="620" height="317" src="/images/geekswithblogs_net/Erik/WcfStorm/WcfStormFunctionalTest(1).jpg" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;               Check out the &lt;a href="http://geekswithblogs.net/Erik/gallery/9896.aspx"&gt;gallery&lt;/a&gt; for more screenshots.&lt;/p&gt;
&lt;p&gt;            &lt;/p&gt;
&lt;p&gt;           Try it out!  Download the trial version below.&lt;/p&gt;
&lt;h3&gt;       &lt;a href="http://www.wcfstorm.com"&gt;&lt;img alt="" width="135" height="34" src="/images/geekswithblogs_net/Erik/WcfStorm/downloadNowButton.png" /&gt;&lt;/a&gt;   &lt;font size="3"&gt;or &lt;a href="http://www.wcfstorm.com/wcf/buynow.aspx"&gt;Buy Now&lt;/a&gt; or&lt;a href="http://www.wcfstorm.com/wcf/learn-more.aspx"&gt;&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;a href="javascript:void(0);/*1239774284042*/"&gt;Learn more&lt;/a&gt;&lt;/font&gt;&lt;/h3&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;So how much does it cost?&lt;/h3&gt;
&lt;p&gt;              Short answer is ... Not so much!  I've priced the tool for the budget conscious. Consider this, I used to work for a company that bought a license for a soap testing tool that costs almost &lt;strong&gt;700 &lt;/strong&gt;USD (that's right7 hundred!) annually per seat. It was a great tool. It had tons of features but the problem was, we rarely used them.  We mainly used it to invoke web service methods and verify that the results are correct.  All the other features that the company paid (dearly) for, were rarely or sometimes never used.  Why pay so much for unused features? &lt;/p&gt;
&lt;p&gt;            So how much does WCF Storm cost? &lt;/p&gt;
&lt;ul&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;strong&gt;Personal Edition&lt;/strong&gt;     : &lt;strong&gt;&lt;font size="3"&gt;14.99&lt;/font&gt;&lt;/strong&gt; USD only (annually/seat ) &lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;Enterprise Edition&lt;/strong&gt;   : &lt;strong&gt;&lt;font size="3"&gt;49.99&lt;/font&gt;&lt;/strong&gt; USD only (annually for 10 seats!)&lt;/li&gt;
        &lt;li&gt; &lt;/li&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;font size="3"&gt;&lt;em&gt;(EDIT : I've finalized the pricing structure for WCFStorm. Please visit &lt;font face="Arial"&gt;&lt;a href="http://www.wcfstorm.com/wcf/buynow.aspx"&gt;http://www.wcfstorm.com/wcf/buynow.aspx&lt;/a&gt;&lt;/font&gt; to view the offers)&lt;/em&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p&gt;                       Not bad, huh? :) For such a low price not only can you test WCF services, it even works on Web services.  if you buy now and be part of the first 100 to purchase WCF Storm, I'd extend your license for 2 years!&lt;/p&gt;
&lt;p&gt;                      &lt;/p&gt;
&lt;p&gt;However, if you think that the price is expensive, drop me an email and we can discuss the price we're both comfortable with.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;I love the price, but why didn't you just open source it like &lt;a href="http://codeplex.com/storm"&gt;STORM&lt;/a&gt;?&lt;/h3&gt;
&lt;p&gt;           I think these words are sufficient to answer that question:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;
    &lt;h4&gt;          Recession &lt;/h4&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
&lt;p&gt;This recession that we all are experiencing right now has also affected myself and my family.  I still have my job but I can't tell whether next month I'd still have it.  Some people had already been let go and management has been awfully quiet on when the next round of layoffs will be.  I have a wife and a lovely  5 year-old daughter to care for.  I also have a mortgage and credit card bills to pay.  My job, which is our main source of income is in an unstable state right now.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;ul&gt;
    &lt;li&gt;
    &lt;h4&gt;          9 millimeter&lt;/h4&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr"&gt;
&lt;p&gt;My wife is 2 months pregnant. During our last visit to the doctor, we found out our baby is about 9 mm in length already. In programmer-speak, our baby is in the Alpha or Beta state right now.  But he/she has already achieved a major project milestone- he/she has a heartbeat!  Oh I am the happiest person in the world right now! We can't wait for him/her to come join us in November later this year.&lt;/p&gt;
&lt;p&gt;     &lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;            &lt;/strong&gt;I had a DONATE button on the codeplex site of STORM and even added it to the Storm application itself.  Its been there for more than 6 months and inspite of the 6000+ downloads, I have yet to receive a single donation.  I know, you'd say, open source doesn't work like that.  One cannot expect donations on open source projects.  It's the spirit of giving and sharing code that matters. Yes, that is true, I believe that as well.&lt;/p&gt;
&lt;p&gt;            But as you can see, I simply can't afford to give out WCF Storm for free right now.  If my family is to weather this difficult time we need to have another source of income. I hope people understand.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;       &lt;a href="http://www.wcfstorm.com"&gt;&lt;img alt="" width="135" height="34" src="/images/geekswithblogs_net/Erik/WcfStorm/downloadNowButton.png" /&gt;&lt;/a&gt;  &lt;font size="3"&gt;or  &lt;a href="http://www.wcfstorm.com/wcf/buynow.aspx"&gt;Buy Now&lt;/a&gt; or &lt;/font&gt;&lt;font size="3"&gt;&lt;a href="http://www.wcfstorm.com/wcf/learn-more.aspx"&gt;Learn more&lt;/a&gt;&lt;/font&gt; &lt;/h3&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/130664.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2009/04/02/130664.aspx</guid>
            <pubDate>Thu, 02 Apr 2009 18:16:40 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/130664.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2009/04/02/130664.aspx#feedback</comments>
            <slash:comments>17</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/130664.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/130664.aspx</trackback:ping>
        </item>
        <item>
            <title>F#: Making records behave like objects</title>
            <link>http://geekswithblogs.net/Erik/archive/2008/10/09/125732.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="2"&gt;The Goal &lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Simulate a class using the Record type&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="2"&gt;How we'll do this&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Create a tool that can translate a number into another format. In particular, we'll convert a number into &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Roman Numerals or &lt;/li&gt;
    &lt;li&gt;multiply it by 10 &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="2"&gt;Why are you doing this?&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;No particular reason. I was just curious.  I was just thinking that if F# did not support OOP, how can I still achieve the same things I was used to doing in C#?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="2"&gt;Ok so here we go..&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;F# record types are simple named types. We can pattern match over it and it is also constructed quite easily. For example&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="435" height="69" src="/images/geekswithblogs_net/Erik/Recordssample.Png" /&gt;&lt;/p&gt;
&lt;p&gt;The record Person contains 2 named fields, which are both strings. Most of the time records are used to hold data but since F# is an FP language, we can also have the fields of the record carry a function.  For example, we can modify the Person record type to instead of having the "LastName" as a string, we'll turn it into a function that computes the last name. Something like, &lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="594" height="67" src="/images/geekswithblogs_net/Erik/Recordssample2.Png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see we have changed the signature of LastName from "string" to "unit-&amp;gt;string". The function "fun -&amp;gt; Guid.NewGuid().ToString() " matches this new signature. (Side note: as a C# coder, this was a big mind shift for me)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Going back to our example, lets define a Converter record type as&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="402" height="41" src="/images/geekswithblogs_net/Erik/CropperCapture[2].Png" /&gt;&lt;/p&gt;
&lt;p&gt;this type holds a string field "x" and "ToNewFormat" field with the signature unit-&amp;gt;string.  The function does not take any parameter because we'll have it use the value assigned to "x" i.e. it will convert the value in "x" into a different format.  If we were using a class, our code (C#) will be something like&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="287" height="163" src="/images/geekswithblogs_net/Erik/CSharpClassrecord2.Png" /&gt;&lt;/p&gt;
&lt;p&gt;and to use it we'd write&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="283" height="74" src="/images/geekswithblogs_net/Erik/CropperCapture[3].Png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So how do we contsruct our F# Converter record so that it would behave essentially like the C# Converter class?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;like this.&lt;/p&gt;
&lt;p&gt;&lt;img width="441" height="250" alt="" src="/images/geekswithblogs_net/Erik/FSRecInstance.Png" /&gt;&lt;/p&gt;
&lt;p&gt;We create a converter function that takes 2 parameters, "numStr" and "myConverterFunction".  NumStr gets assigned to the field "x" while the myconverterFunction is wrapped inside the "intToNewFormat" function which has the signature unit-&amp;gt;string.&lt;/p&gt;
&lt;p&gt;MyConverterFunction was wrapped inside intToNewFormat function because we want this function to work on the value of field "x".  Well actually myConverter function uses the value of "positiveNum" (an int) which was derived from the string value of temp.x.  The "temp" value is of course of type Converter.&lt;/p&gt;
&lt;p&gt;The important part here is that in order for us to acces the instance value of "x" we need add the "rec" keyword in the definition of the value temp.  If we didn't do that we won't be able to access temp.x!&lt;/p&gt;
&lt;p&gt;&lt;img width="441" height="250" alt="" src="/images/geekswithblogs_net/Erik/FSRecInstance2.png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;To call this createConverter function, all we need to do is pass a string and a function that has the signature int-&amp;gt;string&lt;/p&gt;
&lt;p&gt;&lt;img width="859" height="251" alt="" src="/images/geekswithblogs_net/Erik/fsRecordCall.png" /&gt;&lt;/p&gt;
&lt;p&gt;In the code above, we create a romanConverter function that takes a string and creates the instance of the Converter record by passing the string and "RomanConverterFunction.romanConverter" function. The "RomanConverterFunction.romanConverter" function takes an integer and converts it to Roman numerals. For example, if you pass it "1980" it will output "MCMLXXX"&lt;/p&gt;
&lt;p&gt;That's it! whenever we call, &lt;strong&gt;romanNumeralConverter.ToNewFormat(),&lt;/strong&gt; it is converting its instance value of "x" into roman numerals exactly the same way the C# Converter class is working.&lt;/p&gt;
&lt;p&gt;Note that because we are passing around functions we can easily create different kinds converters.  In the above code we created another converter, "multiplier10converter" which merely multiplies a number by 10 (yes, this example is not very good. :-p ).  If we needed a different converter all we need to do is write the code for that converter and pass the new conversion function to "createConverter". Simple.  If we had to do this in OO, we have to through the inheritance-override route.&lt;/p&gt;
&lt;p&gt;Here's the tool in action&lt;/p&gt;
&lt;p&gt;&lt;img width="529" height="235" alt="" src="/images/geekswithblogs_net/Erik/ToolRunning.png" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/125732.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2008/10/09/125732.aspx</guid>
            <pubDate>Thu, 09 Oct 2008 21:29:57 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/125732.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2008/10/09/125732.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/125732.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/125732.aspx</trackback:ping>
        </item>
        <item>
            <title>Should F# be open sourced?</title>
            <link>http://geekswithblogs.net/Erik/archive/2008/09/17/125226.aspx</link>
            <description>&lt;p&gt;F# is an awesome language.  I'd choose to write F# code any day over any language if my work allows it.  The way you are able to concisely and cleanly write code with it is what brought me over. Sure there is an initial overhead (if you we are an OO programmer) in learning all the functional constructs but in the end its all worth it.  Even though you might not be able to use it at work (read : management only wants C#/VB.NET), the way you are writing OO code will definitely be improved.  I for example have come to appreciate Generics and delegates more because of F#.&lt;/p&gt;
&lt;p&gt;Microsoft Research has done such a great job with it and I'm quite sure they will continue to do so.  &lt;/p&gt;
&lt;p&gt;There is no question that &lt;em&gt;"F# as a language&lt;/em&gt;" is great. People do however have a gripe about "&lt;em&gt;F# as a Microsoft product&lt;/em&gt;".  It is not open source nor is it standard like C#. There is a technology-lockin which I presume some fear will later on will translate into a vendor-lockin.&lt;/p&gt;
&lt;p&gt;F# targets mainly the research and financial institutions.  I can not say much about financial companies but research instituions and technology companies are big Linux users.  There is very high likelihood that these people are also open-source advocates.  It will be in their best interest to ensure that the language works perfectly on both Windows and non-windows systems.  This is both a win for the users and for Microsoft.  It would also propel the language forward at a much quicker pace.&lt;/p&gt;
&lt;p&gt;It might be too early to ask this given that the F# CTP was only recently released, but should Microsoft open source F# and get the community involved?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/125226.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2008/09/17/125226.aspx</guid>
            <pubDate>Wed, 17 Sep 2008 19:05:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/125226.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2008/09/17/125226.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/125226.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/125226.aspx</trackback:ping>
        </item>
        <item>
            <title>Observer Pattern in F# : Simplified/Enhanced</title>
            <link>http://geekswithblogs.net/Erik/archive/2008/05/22/122302.aspx</link>
            <description>&lt;p&gt;One of the commonly used design pattern is the &lt;strong&gt;Observer Pattern&lt;/strong&gt; because its just so easy to use and implement.  The classic OO way of implementing it is to have a Subject class having the methods "Attach", "Detach"  and "Notify". The Subject class usually stores the observers in an ArrayList and then when it needs to update the observers then iterates on the list and invokes the "Update" method of each observer. See diagram below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dofactory.com/Patterns/Diagrams/observer.gif"&gt;&lt;img alt="Classic Observer Pattern" src="http://dofactory.com/Patterns/Diagrams/observer.gif" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;In C#, a more elegant way of implementing this is with &lt;strong&gt;Events and Delegates&lt;/strong&gt;.  Here's a nice &lt;a href="http://spellcoder.com/blogs/bashmohandes/archive/2007/03/10/6212.aspx"&gt;sample&lt;/a&gt; implementation.  By using using events and delegates, the code became a lot shorter and straight-forward &lt;/p&gt;
&lt;p&gt;In F#, implementation of the observer pattern became even more concise and elegant.  How come? Take a look at the code below.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;&lt;font color="#333399"&gt;line 11&lt;/font&gt;&lt;/u&gt; : A clean and simple (&lt;strong&gt;one-liner!&lt;/strong&gt;) way of creating events and triggers.  A call to IEvent.create is all it takes&lt;/p&gt;
&lt;p&gt;&lt;font color="#333399"&gt;&lt;u&gt;lines 16 &amp;amp; 17&lt;/u&gt; &lt;/font&gt;: calling "trigger" and passing the correct parameters notifies all listeners of the changeEvent.  We don't even need to check if there are listeners attached. If this is in C# we need to make &lt;em&gt;changeEvent  != null&lt;/em&gt; otherwise a NullReferenceException will be raised.&lt;/p&gt;
&lt;p&gt;&lt;font color="#333399"&gt;&lt;u&gt;lines 28 &amp;amp; 30&lt;/u&gt;.&lt;/font&gt;  In F# Events are &lt;strong&gt;first-class values &lt;/strong&gt;, that means we can pass it around and more importantly we can do all sorts of wonderful things with it using the IEvent module.  For example,  in line 28, we filtered the event, basically saying that we are only interested in events of the &lt;em&gt;Remove&lt;/em&gt; operation.  Now imagine if the Operation type (an enum actually, lines 5-7 ) contains more items such as Update, Delete, AddedThenRemoved, AddedThenUpdated, RemovedAddedAgainThenFinallyUpdated ... (you get what I mean).  If we want to a handle only the Remove operation then we'd have no choice but to break it down using an if-elseif-else or switch-case construct.  It would work but its not going to be pretty.  And this is where &lt;em&gt;IEvent.filter&lt;/em&gt; shines. With just a single line of code (line 28, please ignore the comment above it.), we were able to filter out the event that we are only interested in. Apart from filtering, IEvent also allows us to map, partition, fold, split etc. events.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;&lt;font color="#333399"&gt;lines 25 &amp;amp; 30&lt;/font&gt;&lt;/u&gt; : 2 ways of attaching to an Event.  I'm not very sure what's the difference between these 2. (TODO : Investigate)&lt;/p&gt;
&lt;p&gt;&lt;img height="564" alt="F# Observer Pattern Code" width="622" src="/images/geekswithblogs_net/Erik/fsharpOberserverPatern.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Here's the output! Notice that the "observerForRemove" printed out only the message related to the Remove operation even though the Subject class raised 2 events (one for Add, another one for Remove) in the Notify() method at line 15.  Sweet.&lt;/p&gt;
&lt;p&gt;&lt;img height="138" alt="output" width="613" src="/images/geekswithblogs_net/Erik/fsharpOberserverPaternOutput.PNG" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/122302.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2008/05/22/122302.aspx</guid>
            <pubDate>Thu, 22 May 2008 20:36:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/122302.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2008/05/22/122302.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/122302.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/122302.aspx</trackback:ping>
        </item>
        <item>
            <title>SoapBits is now open source!</title>
            <link>http://geekswithblogs.net/Erik/archive/2008/05/10/122038.aspx</link>
            <description>To everyone who've either sent me an email  or posted a comment asking whether &lt;a href="http://geekswithblogs.net/Erik/archive/2007/09/01/115109.aspx"&gt;SoapBits &lt;/a&gt;can be made into an open source project, well here I am pleased to let you all know that finally it has happened! &lt;br /&gt;
&lt;br /&gt;
SoapBits is now open source and is available at codeplex!&lt;br /&gt;
&lt;br /&gt;
In line with this change, it have given it a new name,&lt;span style="font-weight: bold;"&gt;STORM&lt;/span&gt;. (I meant "STORM"  to be an acronym but I can only come up with &lt;span style="font-weight: bold;"&gt;S&lt;/span&gt;oap &lt;span style="font-weight: bold;"&gt;T&lt;/span&gt;esting for "ST" .  The "ORM"  part I have yet to figure out, so please do suggest if you think of a clever meaning. ;)  )  Another major change is that the tool is now written &lt;span style="font-style: italic;"&gt;mostly&lt;/span&gt; in &lt;span style="font-weight: bold;"&gt;F#&lt;/span&gt;, a language which I believe is a lot more expressive and powerful than C# because of the ease with which it has combined Object Oriented and Functional programming. The user interface part though is still written in C# mainly because F# is not yet fully integrated into Visual Studio.&lt;br /&gt;
&lt;br /&gt;
STORM site : &lt;a href="http://codeplex.com/storm"&gt;http://codeplex.com/storm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
As you all can see below, the UI has also changed a bit but the old functionalities are still there&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=storm&amp;amp;DownloadId=34052" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enjoy the tool everyone! And don't forget to give back and contribute to the project.&lt;br /&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/122038.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2008/05/10/122038.aspx</guid>
            <pubDate>Sun, 11 May 2008 04:12:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/122038.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2008/05/10/122038.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/122038.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/122038.aspx</trackback:ping>
        </item>
        <item>
            <title>String.Replace() in XSLT</title>
            <link>http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx</link>
            <description>&lt;p&gt;Here's a sample template that lets you have the String.Replace() functionality in XSLT 1.0.   The template "string-replace-all" takes 3 parameters and recursively processes the input text string.&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;     text         : main string&lt;/li&gt;
    &lt;li&gt;     replace : the string fragment to be replaced&lt;/li&gt;
    &lt;li&gt;    by           :  the replacement string&lt;br /&gt;
     &lt;/li&gt;
&lt;/ul&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:template&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;string-replace-all&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;text&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;replace&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;by&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:choose&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:when&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;test&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;contains($text, $replace)&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:value-of&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;substring-before($text,$replace)&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:value-of&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;$by&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:call-template&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;string-replace-all&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
          &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:with-param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;text&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #0000ff"&gt;          &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;substring-after($text,$replace)&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
          &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:with-param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;replace&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;$replace&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
          &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:with-param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;by&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;$by&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:call-template&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:when&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:otherwise&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:value-of&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;$text&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:otherwise&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:choose&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:template&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt; &lt;/div&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="font-family: Times New Roman"&gt;&lt;big&gt;&lt;font color="#000000"&gt;Here's how it is called:&lt;/font&gt;&lt;/big&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: Consolas; font-size: 8pt"&gt;&lt;span style="color: #0000ff"&gt;&lt;br /&gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:variable&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;myVar&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:call-template&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;string-replace-all&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:with-param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;text&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;'This is a sample text : {ReplaceMe} and {ReplaceMe}'&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:with-param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;replace&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;'{ReplaceMe}'&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:with-param&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;by&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; &lt;/span&gt;&lt;span style="color: #ff0000"&gt;select&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;'String.Replace() in XSLT'&lt;/span&gt;&lt;span style="color: #000000"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt; /&amp;gt;&lt;br /&gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:call-template&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;br /&gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: #2b91af"&gt;xsl:variable&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;(Edit : Thanks to Marky and granadaCoder for typing out the xslt code in the comments.)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The resulting value of $myVar after {ReplaceMe} is replaced is &lt;em&gt;&lt;strong&gt;"This is a sample text : &lt;font style="background-color: #ccffcc"&gt;String.Replace() in XSLT&lt;/font&gt; and &lt;font style="background-color: #ccffcc"&gt;String.Replace() in XSLT&lt;/font&gt;"&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;For those who are not familiar with XSLT syntax and here's the C# equivalent.  An excellent material for the &lt;a href="http://thedailywtf.com"&gt;thedailywtf!&lt;/a&gt; :)&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="727" height="177" src="/images/geekswithblogs_net/Erik/xsl-str-replaceCallingCSharpTWF.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt; (Note: I'm not so sure, but I think in XSL 2.0 there is already a built-in replace function on strings)&lt;/em&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/Erik/aggbug/120915.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Erik Araojo</dc:creator>
            <guid>http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx</guid>
            <pubDate>Wed, 02 Apr 2008 01:36:09 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Erik/comments/120915.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx#feedback</comments>
            <slash:comments>50</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Erik/comments/commentRss/120915.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Erik/services/trackbacks/120915.aspx</trackback:ping>
        </item>
    </channel>
</rss>
