Click here to Skip to main content
15,898,134 members
Articles / Web Development / HTML

Dynamic Expresso

Rate me:
Please Sign up or sign in to vote.
4.91/5 (44 votes)
18 Jan 2015MIT11 min read 81K   935   72  
Generate LambdaExpression or function delegate on the fly without compilation.
@{
    Layout = null;

    string assemblyVersion = typeof(DynamicExpresso.Interpreter).Assembly.GetName().Version.ToString();
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Web Shell - Dynamic Expresso</title>
    <meta name="description" content="A simple shell for trying Dynamic Expresso in your browser." />
    <meta name="keywords" content="dynamic expresso" />

    <link rel="stylesheet" href="@Url.Content("~/Content/bootstrap.min.css")" type="text/css">
    <link rel="stylesheet" href="@Url.Content("~/Content/bootstrap-responsive.min.css")" type="text/css">
    <link rel="stylesheet" href="@Url.Content("~/Content/webshell.css")" type="text/css">
</head>
<body>

    <header>
        <div class="container">
            <h1>Dynamic Expresso Web Shell</h1>
            <p class="lead">
                <a href="https://github.com/davideicardi/DynamicExpresso">Dynamic Expresso</a> is an expression interpreter for simple C# statements.
                <br />
                Try it now directly in your browser.
            </p>
        </div>
    </header>

    <div class="container">
        <div class="row">
            <div id="terminal">
                <p>Dynamic Expresso version: @assemblyVersion</p>
                @*<p>type "help" for help</p>*@

            </div>
        </div>

        <div class="row">
            <p>
                Dynamic Expresso understands a subset of C# syntax (numeric and string operators, comparison operators, typeof, new, primitive types, Math and Convert classes, ...). 
                It supports single statement expression only. See <a href="https://github.com/davideicardi/DynamicExpresso">documentation</a> for more information.<br />
                In this example all the results are serialized using json to be more human readable.
            </p>
        </div>

        <div class="row">
            <div class="span6">
                <div class="">
                    <h3>Commands examples</h3>
                    <p>
                        Here some expressions that you can try:
                    </p>
                    <ul>
                        <li><code>5 + 2 * 8 / (80 + 9.9)</code></li>
                        <li><code>"Hello" + " " + "world!"</code></li>
                        <li><code>DateTime.Now.AddDays(30)</code></li>
                        <li><code>new DateTime(2020, 2, 13)</code></li>
                        <li><code>string.Format("My name is {0}. Today is {1}", "R2-D2", DateTime.Now.ToShortDateString())</code></li>
                        <li><code>Commands.Count</code></li>
                        <li><code>Commands.Clear()</code></li>
                        <li><code>Commands.GetLastCommands()</code></li>
                    </ul>

                    <p>
                        The <code>Commands</code> variable is just for demostration purpose.
                    </p>
                </div>
            </div>

            <div class="span6">
                <div class="">
                    <h3>credits</h3>
                    <p>
                        <small>
                        shell javascript code is based on the mongulator project (<a href="https://github.com/banker/mongulator">https://github.com/banker/mongulator</a>)<br />
                    Copyright (c) 2009 Kyle Banker
                        </small>
                    </p>
                </div>
            </div>
        </div>

    </div>

    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.9.0.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/webshell.js")"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            var deHandler = new DynamicExpressoHandler({ interpreterUrl: "@Url.Action("Eval", "Interpreter")" });
            var terminal = new ReadLine({
                htmlForInput: DefaultInputHtml,
                handler: deHandler,
                scoper: null
            });
        });
    </script>

</body>
</html>

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 MIT License


Written By
Software Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions