Click here to Skip to main content
15,884,177 members
Articles / Programming Languages / C#

Fluent.Xml.Linq - Exploring the limits of C# syntax

Rate me:
Please Sign up or sign in to vote.
5.00/5 (23 votes)
14 Feb 2010CPOL10 min read 36.5K   76   34  
Exploration of the limits of C# - how much it could be pushed to create Fluent APIs or Internal Domain Specific Languages.
Module Module1

    Sub Main()
        Console.WriteLine(GetFormHtml("Sample ", "Sample 2 lable", "Default value 2"))
        Console.ReadKey()
    End Sub

    Function GetFormHtml(ByVal title As String, ByVal lable As String, ByVal defaultValue As String) As String
        Dim html As XElement
        html = <form method="post" action="http://error.com/SomeForm.aspx">
                   <h2><%= title %></h2>
                   <p>Description of the form here...</p>
                   <p><%= lable %><input type="text" value=<%= defaultValue %>/></p>
                   <p>
                       <input type="submit" value="OK"/>
                       <input type="reset" value="Cancel"/>
                   </p>
               </form>
        Return html.ToString()
    End Function

End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder OPE AG
Switzerland Switzerland
Olli is a .Net developer and architect.

He specializes in Asp.net MVC and other web technologies, XML and lately Domain Specific Languages.

Olli is originally from Finland, but currently works for his own one-man-initiative OPE AG (www.ope.ag) from Switzerland. He has over 10 years of experience as one of the founding partners and Chief Technology Officer of Quartal group of companies (www.quartal.com).

Comments and Discussions